I am trying to refresh documents in the backend using lotusscript. When I run the code below, I get the 'not saved' error returned for every document in the view. Whereas when I run the formula equivalent '@Command([ToolsRefreshSel
) on the same set of documents, no error is returned and the computed fields on the form are correctly looked up and recomputed. The following is a script i picked up from the net and modified it a bit. I am an absolute newbie on script -- quick help will be sincerely appreciated.
Also, as per the Agent Log, the agent seems to run on all documents in the database, even though the view has much lesser documents. In the agent properties for Target, I have specified 'All documents in the database'. But the only other option is 'new and modified documents', which is not an acceptable option in my case, as I need to refresh daily even the older documents.
Dim s As New NotesSession
' declare object variables
Dim db As NotesDatabase
Dim v As NotesView
Dim doc As NotesDocument
Dim docNext As NotesDocument
' instantiate objects
Set db = s.CurrentDatabase
Set v = db.GetView("Log_Refresh")
v.AutoUpdate = False
Set doc = v.GetFirstDocument
Do Until doc Is Nothing
Set docNext = v.GetNextDocument(doc)
If doc.computewithform(True, False) Then
Call doc.save(True, False)
Messagebox "Document " & doc.UniversalID & " was not saved"
Delete doc ' remove doc from cache (does not delete from database)
Set doc = docNext
' refresh the view (don't bother)
' Call v.Refresh