Domino Code Fragment

Code Name*
LotusScript Agent to Recalculate Documents on a Schedule
Date*
04/29/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.3.138.174.95
Description*
LotusScript Agent to Recalculate Documents on a Schedule
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
IMPORTANT NOTE: The above is a sample script, provided only to illustrate one way to
approach this issue. In order for this example to perform as intended, the script must be laid out exactly as indicated below. Notes Support will not be able to customize this script for a customer's own configuration.
Files/Graphics attachments (if applicable): Code:
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. Refer to the document "ComputeWithForm Does Not Compute
Default Values Containing @Db Commands" (#146472) for more information.


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
For x=1 To collection.count
Set doc=collection.GetNthDocument(x)
Call doc.ComputeWithForm(False,False)
Call doc.save(False,False)
Next