LotusScript Agent to Recalculate Documents on a Schedule
Product:
Lotus Notes > Lotus Notes > Versions 6.0, 5.0, 4.6, 4.5, 6.5
Platform(s):
Platform Independent
Doc Number:
1099014
Published 27.08.2004
Technote
Problem
How can you have documents recalculate in the background so that computed fields are up to date and accurate? For example, a database has documents that do @DbLookups, @DbColumns, etc. to other documents that are occasionally updated with new information. If a document is opened, @Db formulas will not recalculate until you press F9; therefore, the data may not be accurate.
Solution
The following script can be run as a scheduled agent to 'tickle' and save documents on the back end. The method that is actually doing the recalc is the ComputeWithForm method of the NotesDocument class. This method will recalculate @Db formulas only when run on Notes 4.5a (and above) clients and servers.
Note: If a form contains a Computed field (for example, a field called "Count") with a formula which is based on its own field value (for example, "Count+1"), then the ComputeWithForm method is not suitable for use in refreshing that document. This is because the ComputeWithForm method triggers recalculation twice. For more information on this topic see the related document, "Is it Possible to Refresh Documents Using LotusScript ?" (#1092630).
IMPORTANT NOTE: The following is a sample script, provided only to illustrate one way to approach this issue. Notes Support will not be able to customize this script for a customer's own configuration.
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
Do Until doc is Nothing
Call doc.ComputeWithForm(False,False)
Call doc.save(False,False)
Set doc=collection.GetNextDocument( doc )
Loop
Related Documents:
Is it Possible to Refresh Documents Using LotusScript ?
Document #: 1092630 (176609)