Brian Dunning's FileMaker Custom Functions

RF_Audit ( LogField ; Watchlist )

Prepends an audit log of changes to fields in Watchlist to LogField

  Average rating: 4.2 (37 votes) Log in to vote

Peter Vinogradov   Peter Vinogradov - Show more from this author

Share on Facebook Share on Twitter

  Sample input:
RF_Audit ( Data_Audit; "tf_Reps[2] & nf1")
  Sample output:
[4/28/2007 12:56:19 AM] User Admin ------ <tf_Reps[2] > to |World| from |Hello|
[4/28/2007 12:56:19 AM] User Admin ------ <nf1 > to |14| from |12|
{formatting not shown}

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Inspired by Ray Cologon's SuperLog technique, this recursive CF is used to capture changes to specified fields. Typically, the "LogField" is a text field stored in the table you want to audit. It is defined as an auto-entry calc that triggers this CF whenever modifications are made to fields in the watchlist.

This autoentry calc requires a bit more fuss than the SuperLog method, since you have to explicitly define field triggers AND a string of Watch fields to pass to the function. In the example above, Data_Audit would be defined as follows:
-------------
Let (
[
Triggers = tf_Reps[2] & nf1;
WatchList = "tf_Reps[2] & nf1";
];
RF_Audit ( Data_Audit; WatchList)
)
-------------
The tradeoff is that the function is not context-dependent, and therefore no separate logic is needed for modifications made by script.
This function also includes formatting logic for the log.
Function has not been seriously field tested or put up against a large watchlist so it may turn out to be slow under load. Feedback appreciated (pvino at optonline.net)

 

Comments

Joan Subirós   Joan Subirós, fmSuit
Nov 11, 2019
Hello,
How can I "audit" if the user edit or modify a relational field in a portal ???
Thanks.
 
Andrew Mallison   Andrew Mallison
Mar 18, 2024
Can I suggest you drop the formatting, 'User ' & '------' etc to keep it simpler and smaller
 
Andrew Mallison   Andrew Mallison
Mar 18, 2024
Also remove the ';' off the WatchList line in your example.
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: