Sunday, 6 March 2011

Handy Selected Documents Totals

This code snippet take a view, takes the selected documents and adds together a value from a particular field.

Add this to a simple lotusscript agent and call it from the actions menu.  Rename the field named "BankValue" below.

Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument

Set db = session.CurrentDatabase
Set collection = db.UnprocessedDocuments
Set doc = collection.GetFirstDocument()

total = 0
While Not(doc Is Nothing)
total = total + doc.BankValue(0)
Set doc = collection.GetNextDocument(doc)

Messagebox total, 0+64 , "Total"

No comments:

Post a Comment