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

This was last published in December 2002

Dig Deeper on Domino Resources - Part 6

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

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

SearchExchange

SearchContentManagement

Close