Manage Learn to apply best practices and optimize your operations.

Update (Refresh) Computed Fields In Selected Documents

I have a very large database that computes job payroll amounts via a 'Rate'
field. The problem is, this field is computed so the workers can't give
themselves a raise. My company recently had a retro-active pay increase that
affected well over 200 documents. I made an Agent with a simple action that
modified the 'Rate' field and ran it on all the selected documents, but I
needed a way to refresh each individual document so the rate change computed
through to the invoice total. I wasn't about to manually open, refresh and
save each document, so I wrote a simple LotusScript to do the dirty work. It
creates a notes document collection of all the documents selected in the
database and runs the script on those docs.

Create an action in the database where you need to refresh documents. Label it
'Script Refresh Docs' or something like that. Set it to act on 'Selected
documents.' Select Run 'LotusScript' and place the following code in the
Declarations and Initialize sections of the Agent.

This script is very flexible, as there isn't any database or document-specific
information in the script. Simply paste the Agent into the database, open it
in the client, select the documents that you want to refresh in a View and run
the Agent from the Actions menu. Enjoy!
Dim nuiw As notesuiworkspace
Dim nuidb As notesuidatabase
Dim ndb As notesdatabase
Dim ndoccol As notesdocumentcollection
Dim ndoc As notesdocument
Dim nuidoc As notesuidocument

Sub Initialize
Set nuiw = New notesuiworkspace
Set nuidb = nuiw.currentdatabase
Set ndb = nuidb.database
Set ndoccol = ndb.unprocesseddocuments 'this collects the flagged documents

For j = 1 To ndoccol.count
Set ndoc = ndoccol.getnthdocument(j)
Set nuidoc = nuiw.editdocument(True,ndoc)

Call nuidoc.refresh
Call nuidoc.close

End Sub

Dig Deeper on Domino Resources - Part 4

  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/ community. These cheat ...