Update field on responses (to responses) once

I have a view, invlouding maindocs, respdocs, resp-to.resp-docs.

I have a function (that works) to update a field (“ReaderList”) in Responses when this field is changed in the maindoc.

This lies in PostSave + a Function; UpdateResponses

But; the database has been used before this agent was created, so there can be inconsistance between readers rigths in main docs / responses.

Therefore I would like to run a agent once to make sure all resp / resp-to-resp have inherited the field from the maindoc.

I’ve tried the @Command ToolsRefreshAllDocs, but this gives an error message regarding UI-docs.

I would like to create an agent to do this without opening the docs.

Anyone who could help me?

All help appreciated.

Subject: Update field on responses (to responses) once

This code agent for you

Sub Initialize

Dim session As New NotesSession

Dim db As NotesDatabase

Dim collection As NotesDocumentCollection

Dim doc As NotesDocument 



Set db = session.CurrentDatabase

Set collection = db.AllDocuments



Set doc = collection.GetFirstDocument()

While Not(doc Is Nothing)  

	If Not doc.IsResponse Then Call 

Update_Response(doc)

	Set doc = collection.GetNextDocument(doc) 

Wend

End Sub

Sub Update_Response(doc As NotesDocument)

Dim dc_response As NotesDocumentCollection 

Dim response As NotesDocument



Set dc_response=doc.Responses

If dc_response.Count>0 Then

	Set response = dc_response.GetFirstDocument

	While Not  response Is Nothing

		Call response.ReplaceItemValue("ReaderList",doc.ReaderList)

		Call response.Save(True,True) 

		Call Update_Response(response)

		Set response =dc_response.GetNextDocument(response) 			

	Wend

End If

End Sub