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).
- 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