Do you use an audit log system for Karbon? Your own?
We have created audit log systems for one of our custom projects based on Karbon, however it isn’t in the default feature, nor are there plans to add it (at least for the near future). @lance might want to weigh on with some recommendations.
Karbon_Kontroller is well suited to build an audit log because it uses transactions, but maintaining a true audit log would be restrictive. I haven’t written up the specifications for what it would take to capture a true audit log, but here are the basic rules:
- All create, edit, & delete must happen in Karbon_Kontroller to be audited.
- Pre & Post must be captured before & after all edits (captured as JSON in a file called Karbon_Audits)
- Auto Enter Calculations can NOT be used in field definitions because this can cause changes during the commit. (same for lookups)
There are other rules depending on how reliable you need the audit log to be. I’d be happy to discuss further based on your needs.
Is this a valid rough sketch?:
- Capture Pre values in one JSON object and the Post values in another JSON.
- Compare the two JSON objects and create a new one consisting of only the fields that was updated.
- Write to AuditLog by looping the JSON.
Do you know of a custom function that can compare two JSON objects and output a new JSON that has only the values of the updated fields? Maybe Karbon already have a CF or CF’s in cooperation that can do this?
The steps above are correct.
I haven’t created a custom function and currently use a script. It should be a custom function now that we have the ability to use While loops in custom functions.
What’s your timeline? I can share the script with you much sooner than the custom function.
I don’t have a timeline since it’s kind of part of my self-educational project.
I’m really interested in both the script and a custom function - should I send you an email?
I’m thinking that the Audit Log should be feed with field id, field name, base table id, base table name - plus file id and file name if you like me have multiple data files to be logged. Do you agree on that?