Web Application. I would like to update multiple response docs once the status of the parent document is changed. @setdocfield works fine, but only for one response document… the rest of the response docs remain unchanged (I guess its not looping). Not very good at Lotusscript, but I think that’s my only option?
Subject: Update field in multiple response docs from parent doc
Run a scheduled agent (every 5 minutes) to do this for you after save. I would not use the webquerysave event for it, because either way it will not be real time and not using the webquerysave event will enhance the useability of the application.
Subject: Try the following…
in the Postsave Event of your form (note that this will work only on Responses, not Response to Responses)…Dim dc as NotesDocumentCollection
Dim doc as NotesDocument
Set doc = Source.Document
Set dc = doc.Responses
Call dc.StampAll(“YourField”, “YourValue”)
Subject: RE: Try the following…
can’t use PostSave on the web.
Subject: Sorry, meant the WebQuerySave Agent.
Subject: Update field in multiple response docs from parent doc
Pretty much. Create a LotusSCript agent to be used as a WebQuerySave on the parent form. Set it’s target to “none”, and make sure it’s running as an id with at least Editor access to the database (preferably an administrative id). The code is really pretty simple:
Dim s as New NotesSession
Dim context as NotesDocument
Dim responseColl as NotesDocumentCollection
Set context = s.DocumentContext
Set responseColl = context.Responses
If Not reponseColl Is Nothing Then
Call responseColl.StampAll(“FieldName”,context.GetItemValue(“OtherFieldName”)(0))
End If
Subject: RE: Update field in multiple response docs from parent doc
Thanks for your help! One complication. There will be response to response docs involved. If it helps, I carry forward the parent doc id in a field called ‘OriginalREF’ on all response and response to response docs.
Subject: RE: Update field in multiple response docs from parent doc
If you are carrying the id of the main doc forward, then create a view sorted on that value and use GetAllDocumentsByKey to get the collection, then StampAll to update. If the main doc id is not available, then the recursion involved will make the code take far too long for a WQS. (You can flag the status change in the browser, too, in order to avoid the WQS if the status is unchanged.) StampAll is remarkably fast, but even it can get bogged down if the document count is large. Test first, then use File Save’s scheduled agent idea if performance is not up to usability standards.