Updating documents via script

I have a database that has date calulations for each document. There is a date started field on every doc and that date is subtracted from the current date to compute an Elapsed Time field. Problem is that in order for the docs to have the Elapsed Time field updated each doc must be edited and saved manually. I tried the agent below but the docs were not recalc’d when using the stampall method. I am seeking the best way to loop through the entire view and open/edit each doc then save it so that the Elapsed Timne field gets updated each night. This would be best suited as a backend agent that runs during the night (11:00p). Any suggestions on the best approach would be appreciated.

Thanks in advance

Current agent:

Dim session As New NotesSession

Dim db As NotesDatabase

Dim dc As NotesDocumentCollection



Set db = session.CurrentDatabase

Set dc = db.AllDocuments

Call dc.StampAll("AgentStatus", "Document Touched by Agent")

Subject: Updating documents via script

I would loop through and simply calc that one field, not calc the whole document.

dim doc as notesdocument

set doc = dc.getfirstdocument

do while not ( doc is nothing )

doc.ElapsedTime = YourCalculation

call doc.save ( false, false )

set doc = dc.getnextdocument ( doc )

loop

Subject: Updating documents via script

If your elapsed time field is computed then the following in an agent would work:

@Command( [ToolsRefreshAllDocs] );

@All