Selected Document Agent

Hello,I have created in a post open script using GetDocumentbyKey a field that is updated when the document is opened.

I do not want to open and close each document and @command(ToolsRefreshSelectedDocs) will not run the post open script.

I am looking for an agent to open and close all selected documents.

Any ideas where I should begin?

Subject: Selected Document Agent

I would just create a backend agent which fixes all fields once.

Subject: RE: Selected Document Agent

Hello,all of the back end is in the form already.

The documents are being processed fine by opening and closing them. I just do not want to do it manually :slight_smile:

Is there a LS agent that just opens and closes each selected document or all documents ?

Subject: RE: Selected Document Agent

I think Mika’s point was that you should REcode the field value that needs updating into a script agent that will set it on the selected documents without the need to open and close them… which would not be a very elegant option anyway.

Subject: RE: Selected Document Agent

Unfortunately I can not rewrite the form. I am not the original developer of the database. The original developer made use of form events to calculate the document. I only added an additional field to the form and modified the postopen event. Newly created documents are being procesed updating my field. Existing documents once opened and closed work also processing the post open event. I wish I new how to rewrite the code but I am a novice at best :slight_smile:

Subject: RE: Selected Document Agent

You don’t need to open and close the Form, just create an backend agent like I suggested earlier. If you have a view which shows all documents using your Form, you could write an agent like:

Sub Initialize

Dim session As New NotesSession

set db=session.CurrentDatabase

set view=db.GetView(“YourView”)

view.AutoUpdate=False

set doc=view.GetFirstDocument

While Not doc Is Nothing

set nextdoc=view.GetNextDocument(doc)

doc.ComputeWithForm True,False

doc.Save True,False

set doc=nextdoc

Wend

End Sub