FORUM PLAN UPDATE: Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.
Tim Holt 22.Apr.17 07:43 PM a Web browser Notes Client All Releases All Platforms
I am using some code that I found on the Forum to track all the Field changes in a document by putting comment in History section. It works pretty well except for 2 data types - dates and Rich Text.
If a value is in a Date field then it ALWAYS generates an entry for that field even if the field has NOT been changed. The debugger shows both old and new values to be exactly the same.
For Rich Text - it NEVER generates an entry when altered. In the debugger, it is getting the old value from the front end AND the back end, so it thinks there is never a change. I have tried a computed field with Abstract formula and same result.
Other than those two cases the code catches all the other field changes. Here is my code for review. Hopefully, someone can shed some light on how to make this work.
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Dim session As New NotesSession
Dim ROSIview As NotesView
Dim originalDoc As NotesDocument
Dim whichField As String
Dim newValue As String
Set db = session.Currentdatabase
Set doc = source.Document
If Not source.IsNewDoc Then
Set ROSIview = db.getview("vwLkupByUNID")
Set originalDoc = ROSIview.GetDocumentByKey (Doc.UniversalID) 'Get handle on unchanged backend doc by using UNID.
Forall field In doc.Items 'Search thru all fields checking for any changes made.
whichField = field.name
newValue = Cstr (field.text) 'Get value in front-end field so can compare to determine if it has been changed.
If (Left(whichField,1) <> "$") Then 'Skip all reserved fields beginning with "$".
oldValue = Cstr (originaldoc.GetitemValue( whichField )( 0 )) 'Get field in backend that has not been changed yet.
If oldValue <> newValue Then 'Compare backend value with frontend value and add entry when they are not the same.
entry = Chr$(10) + Now() + " " + session.CommonUserName + " changed " + whichField + " from " + oldValue + " to " + newValue