NetTalk Central

Author Topic: Best approach for history log / audit trail  (Read 1936 times)

vsorensen

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
    • Email
Best approach for history log / audit trail
« on: November 11, 2009, 10:01:24 AM »
I would like to be able to write out a log that details if a record was deleted, or if a value in a particular field was changed.  It needs to include the original or deleted value.  I thought it would be fairly straightforward, but after trying a few alternatives I have yet to get it working reliably.

(I've tried putting code in both "pre" and "post" change embed points, and saving the initial value to a session variable, but there were quirks such as the saved session value getting changed when the form was called in the update stage).

What is the best way to provide an audit trail that includes the "original" values after a change or deletion?

Is there an example I've missed?
« Last Edit: November 11, 2009, 04:24:38 PM by vsorensen »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11183
    • View Profile
Re: Best approach for history log / audit trail
« Reply #1 on: November 15, 2009, 10:34:02 PM »
Hi Vince,

The basic problem, as with all logging, where you want to include the record "before the change" is that you need to make a snapshot before the change.

I think though yo may be approaching this from the wrong direction. For Delete's anyway, the easiest way to log them is via the ABC DeleteRecord method. The Web stuff is using ABC so by adding code to the DeleteRecord you catch all the deletes regardless of where they happen.
(Another way of doing this is as a "client-side-trigger" in the dictionary.)

For updates you need to embed code in pre-update, and post-update. (you can also do this with Deletes if you like, although there you'd use pr-delete and validate-delete)

You can't use the "normal" session values for your saved copy - as those will be overwritten by the "normal" functioning of the form. I recommend saving the whole record into a session value rather, using your own session value name.

Cheers
Bruce