This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Feb 21, 2012, 5:22 PM
68 Posts

How do you create an audit trail of changed field values?

  • Category: Other
  • Platform: Windows
  • Release: 8.5.2
  • Role: Developer
  • Tags:
  • Replies: 4
I have a requirement in one database to keep an audit trail of any changed field values (the list is finite, it's not ALL the fields on the form).  I have a script library that does this in the Notes Client, but is using front end values.  So, I can't use this code from an agent that I call from a button on an xPage, as that is back end.
 
My current code, on QueryClose, creates a section in a rich text field.  The section title is the user name and date/time, and each field value that has changed is listed in the section. 
 
Is anyone doing an audit trail, and if so, how?
 
 
Feb 22, 2012, 9:32 PM
272 Posts
Re: How do you create an audit trail of changed field values?
Hi,
 
you can use the QueryOpen & QuerySave routines of a datasource to implement the same procedure as used in "good old" Lotus Notes applications. This is how I implemented audit trails to my XPages apps.
 
Hope this helps
Sven
 
Feb 23, 2012, 6:45 AM
129 Posts
Re: How do you create an audit trail of changed field values?
If you want a general purpose solution, there's Audit Manager on OpenNTF:
http://www.openntf.org/projects/pmt.nsf/ProjectLookup/Audit%20Manager 
Feb 23, 2012, 12:23 PM
13 Posts
Re: How do you create an audit trail of changed field values?
This may be overkill for you...but I'm involved in a web project where we are using backing beans, lots of RESTful urls to get data from our beans.  We have to audit absolutely everything (requirement), button presses, every single field change (originally it was just about every keystroke!!!), logins, logouts...as you can imagine, the volume of audit data is huge.  We push it via a web service to a SQL data store, we send in real time, and use a batch process to catch any transfers that fail.
 
If we not had not had a stack of legacy code in Lotus Script, we would have gone this way:  http://www.mindoo.de/web/blog.nsf/dx/22.07.2009175255KLELM7.htm?opendocument&comments
 
...but we already had an audit process in place.   Ours is in Lotus Script, all back end, but the following method would work for java as well, if you are auditing the Notesdocument as opposed to a representation of the NotesDocument as a java object as above (which is what we do when getting our NotesDocument data...we then convert it to JSON).
 
Get the NotesDocument you need to change, create a temporary NotesDoc, copy all fields to the temp document...we store this in a list object and give it a ListTag of START, then start doing something to your document which changes field values, then, whenever you want to take another "snapshot" create another temp notesdocument and copy all the fields to this temp document, put in list with new ListTag, e.g. PROCESS_ONE.  99% of the time we just have START and FINISH.  Then you loop across all fields on first START and see if the corresponding field exists on FINISH, compare fields, if any differences, you can move this to an "audit" document.  Now cycle across all fields in the FINISH as you may have added new fields which didn't exist before.  Add those to the audit document.  Now you have an audit doc with all diffs.  The reason we use temp docs is that we were getting into issues with DateTime and Number fields, if your audit doc has notes fields on it, then you can do whatever with DateTime --> ISO string conversions when you decide to display\ move to your audit datastore.
 
This functionality is built into a "base" class we have, our "working" class, say a WebOrder, "extends" our base class, so we just do:
Dim wc as webClass()
 
'//  get your back end doc..
set wc = new WebClass(doc) '//   the BaseClass.new() method automatically creates a "START" snapshot, even if a new doc, with no fields on it, in which case on submit, audits every new field.
 
'//  do some stuff to your doc
call wc.createLineItems()
'// or...
doc.replaceItemValu("SomeField", 999)
 
'// ...we have amethod that allows us to take a snapshot of the doc, if you wanted...
wc.takeSnapshot()
 
'// but on submit(), it automatically takes a snapshot and creates an audit log
call wc.submit()
 
 
Hopefully this might give you some ideas,
 
Regards,
 
Nick
Feb 23, 2012, 6:30 PM
68 Posts
thanks! now having an issue with date fields...
I've almost got it working.  I'm using the postOpenDocument event to create sessionScope variables for all the fields I want to audit.  Then in the "Save" button, I compare the current values of those fields to the variables, and write a line of text for each change.  Then I put that text into an audit field.
 
The only problem I'm running into now is auditing date fields.  If the fields are blank, there's no issue.  But if there's an existing value in a date field when I open the document, the sessionScope variables aren't capturing that information.  I'm using currentDocument.getItemValueDateTime() in the postOpenDocument event, but for date fields, that always returns "null". 
 
That means that every time I open a document, if there's an existing value in one of those date fields, I get an audit trail like this (when I've made NO changes to the document):
dateField1 changed from null to 02/23/2012 12:00 PM EST
 
I'm using currentDocument.getItemValueString() for the text fields, and they are working properly.
Has anyone seen this behavior?  Is this a bug?? 
  

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal