1
votes

A business owner of my ticket tracking app in Xpages wants to track every change to the document. If a user opens the doc in edit mode but doesn't change anything, then no tracking. If, however, they open up a document and change one field, I have to capture that.

Here is my solution. When a user edits a doc, I create a "shadow document", which is a "before" vision. When the user saves I am comparing field for field for changes, and then acting appropriately.

Is there a better way to do this?

2
A couple unique times I had a use case (with a relatively small amount of fields) where I've copied the pre-edit values into a viewScope'd HashMap when the user triggers "edit" mode, then immediately prior to my save event, I do a comparison of current to previous values. This means I can observe exactly what has changed (and when and by whom), where you store that could be anywhere.Eric McCormick
I have been trying to implement this and have really been struggling. If you find an easy way to implement please let me know.Patrick Sawyer

2 Answers

1
votes

This is another good use case for Java beans. If you create a bean which sits between XPages-UI and Domino back-end document then you can easily track field changes.

Karsten Lehmann wrote a blog about it some time ago.

1
votes

... and you could use the OpenNTF Domino API that has functions for exactly this. As far as I remember there is an example of this in the demo database. Not sure if it is also in the new version of the demo database - but then you may just need to find an older version (e.g. for milestone 4.5 where I saw this).

/John