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!
Declarations
Dim nuiw As notesuiworkspace
Dim nuidb As notesuidatabase
Dim ndb As notesdatabase
Dim ndoccol As notesdocumentcollection
Dim ndoc As notesdocument
Dim nuidoc As notesuidocument

Initialize
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.save
Call nuidoc.close
Next

End Sub

Dig Deeper on Domino Resources - Part 4

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close