Domino Code Fragment

Code Name*
Update a field in response documents after it is changed in
the parent document?
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.3.149.234.141
Description*
How do you update a field in response documents after it is changed in
the parent document?
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:
Assumptions:
1) The name (or synonym) of the Response form is "TASK" and it inherits field values.
2) The name of the field to synchronize is "STATUS" in both Project and Task forms. This

   is computed when composed to inherit from the parent form.

Include the following Script code in the QuerySave event of the 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
 Set Collection = Doc.Responses
 Set Doc = Collection.GetFirstDocument
 ParentStatus = Source.FieldGetText("STATUS")
 While Not ( Doc Is Nothing )
   Form = Doc.GetItemValue("Form")(0)
   Status = Doc.GetItemValue("Status")(0)
   If (Form = "TASK")And (Status <> ParentStatus) Then
     Call Doc.ReplaceItemValue( "STATUS", ParentStatus )
     Call Doc.Save (True, False)
   End If
   Set Doc = Collection.GetNextDocument(Doc)
 Wend
End Sub