Manage Learn to apply best practices and optimize your operations.

Get the previous values of fields in WebQuerySave agent

This tip describes how to Get the the previous values of fields in WebQuerySave agent.

There are situations where you need to know the previous and current value of fields at the same time:

  • Logging of changes in a document on a field level.
  • Validation of the new value based on the previous value (this is crucial when developing workflow application and the field is used as the document progress status)

Coming from the AS/400 I am quite used to have triggers getting the information for me. with this in mind I was looking for a way to emulate the AS/400 trigger. (At least for the update event).

The solution


- Create a view with one column (I called it DocumentsByUniqueID) Set the Column formula to: @Text(@DocumentUniqueID) Make sure you sort this Column.

- In your WebQuerySave agent

To get the saved version of the document simply get it from view DocumentsByUniqueID.

Dim Session    As NotesSession 
Dim DataBase As NotesDatabase
Dim View         As notesview

Dim DocumentC As notesdocument
Dim DocumentP As notesdocument

Set Session  = New NotesSession
Set DataBase = Session.CurrentDatabase

Set DocumentC = Session.DocumentContext 

Set view = DataBase.GetView( "DocumentsByUniqueID" )

Set DocumentP = view.GetDocumentByKey( DocumentC.UniversalID  )
'A sample how to use DocumentC and DocumentP fields.
if DocumentC.status(0) <> DocumentP.status(0) then
End IF

Dig Deeper on Domino Resources - Part 6

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials'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 ...