Monday, September 26, 2011

Take a value in the parent document and push it down into all the response documents

The following LotusScript which will take a value in the parent document and push it down into all the response documents. Place the script in the Querysave event of your parent form.

Sub Querysave(Source As Notesuidocument, Continue As Variant)
     Dim Collection As NotesDocumentCollection
     Dim Doc As NotesDocument
     Dim Form, ParentStatus, Status As String
    
     Set Doc = Source.Document
    
     If Not Source.IsNewDoc Then
          Set Collection = Doc.Responses
          Set Doc = Collection.GetFirstDocument
          ParentStatus = Source.FieldGetText("FieldInParentDocument")
                   
          While Not ( Doc Is Nothing )
               Form = Doc.GetItemValue("Form")(0)
               Status = Doc.GetItemValue("FieldInResponse")(0)
              
               If (Form = "Response Form") Then
                    Call Doc.ReplaceItemValue( "FieldInResponse", ParentStatus)
                    Call Doc.Save (True, False)
               End If
               Set Doc = Collection.GetNextDocument(Doc)
          Wend
         
     End If
End Sub

No comments:

Post a Comment