Field values carry to another Form

kevsh
kevsh used Ask the Experts™
on
If I have a CUSTOMER field and want that same value carried over to the response of that document, how would I do that.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
In the form properties of the response document, select the option "Formulas inherit values from selected document". Then set the value (if computed) or default value (if editable) of the field in the response document to the name of the field in the original document. That should do it.

Hope this helps.

Scott
First I recommend NOT to store (save) the customerfield in the responses. Use a computed for display field instead:
@GetDocField(@Text($Ref); "<parent customer field>")

This way you don't have to update!

$Ref is where responses store their parents' unique id.

If you insist though, start by creating a view like with following selection formula:
SELECT @IsResponseDoc
Make sure in that you deselect "show response documents in hierarchy" (view properties, 2nd tab, 4th checkbox)
Column 1 (sorted; ascending): @Text($Ref)

Let's name this view "ResponseLookupByParentID".

On the parentform, in the Postsave-event, put following code:

Sub Postsave(Source As Notesuidocument)
     Dim Session As New NotesSession
     Dim Db As NotesDatabase
     Dim Vw As NotesView
     Dim Coll As NotesDocumentCollection
     Dim RespDoc As NotesDocument
     Dim CurrDoc As NotesDocument
     Dim CurrUNID As String
     Dim CurrCust As String
     
     Set CurrDoc = Source.Document
     CurrUNID = CurrDoc.UniversalID
     CurrCust = CurrDoc.Customer(0) ' Customer-field on parent doc.
     
     Set Db = Session.CurrentDatabase
     Set Vw = Db.GetView("ResponseLookupByParentID")
     Set Coll = Vw.GetAllDocumentsByKey(CurrUNID)
     Set RespDoc = Coll.GetFirstDocument
     Do While Not RespDoc Is Nothing
          Call RespDoc.ReplaceItemValue("Customer", CurrCust)
          Call Respdoc.Save(True, True)
          Set RespDoc = Coll.GetNextDocument(RespDoc)
     Loop
End Sub
So... you don't want any future name changes to inherited by the responses?

Congrats Scott, didn't think it would be that easy!  ;-))
 

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial