Mac OS X
Components Crossplatform Mac & Win Server Client Old Guides Examples
New in version: 7.2 7.3 7.4 7.5 8.0 8.1 8.2 8.3 8.4 8.5 Statistic
Log record change.
|Component||Version||macOS||Windows||Server||FileMaker Cloud||FileMaker iOS SDK|
|timestamp||Pass here the timestamp field you added for auditing to the table.||AuditTimeStamp|
|TableName||The name of the table.||"Firma"|
A list of field names to ignore. Global fields and those set with Audit.SetIgnoredFieldNames are always ignored.
DescriptionLog record change.
In order to setup this for a table, please add two fields to the table. First a field called AuditTimeStamp which is of type timestamp. In the options enable in the Auto-Enter tab the option to set a new timestamp on modification. Next create a new field AuditState and make it a calculated value with the calculation MBS( "Audit.Changed"; AuditTimeStamp; TableName ). The Field "AuditTimeStamp" can be renamed to something like "sAuditTS" but has to be correctly referred to and should be included in the "Audit.SetIgnoredFieldNames" call if changed. By passing here an auto entered modification timestamp you make sure the plugin is informed about all changes to this table. Please uncheck the checkbox for "Do not replace existing value of field (if any)".
For logging you need a table named AuditLog with a few fields. Required are fields named FieldName, FieldHash, TableName, RecordID. Optionally you can add more fields: FieldValue, FieldOldValue, FieldType, UserName, IP, CurrentTimestamp, TimeStamp, CurrentTime, CurrentDate, Action, CurrentHostTimeStamp, PrivilegeSetName, AccountName, LayoutNumber, ApplicationVersion, FileName, HostApplicationVersion, HostName, HostIPAddress, LayoutName, PageNumber, LayoutTableName, TableID, FieldID, CurrentTimeUTCMilliseconds, ScriptName and WindowName.
The plugin will fill those fields with values evaluated from Get() function. FieldOldValue is only filled if we find an older log entry for the field based on the hash. With 4.2 plugin you can also use field Platform to know if plugin was executed on server or client.
You can get access of a record logged if you use a script tigger to set the AuditTimeStamp field with a new timestamp whenever a record is loaded.
This functions work even with separated files where data and layouts are in separated database files. The AuditLog table can be in a separated file as long as the plugin can can find a table occurence named "AuditLog", referencing to the original table which may be located in another FileMaker file and a layout based on this table occurence, named "AuditLog", to write into the log.
The two fields AuditTimeStamp and AuditState can have different names. In that case we recommend to call Audit.SetIgnoredFieldNames in order to have the plugin ignore those fields. Or pass the field names to this function.
To get all your existing records introduced to this Audit Function, move over all records in a loop in a script and call Audit.Changed to log the current one. This helps to fill the FieldOldValue field.
And finally if you like, you can even built yourself an undo mechanism by restoring changes.
On FileMaker 10 the Audit functons only work if tables and base tables have same name. Also we can't record FieldID or TableID on FileMaker 10. For FileMaker 11 and 12 everything works nice.
In the fields to ignore parameters you can pass extra values "FieldName|Value" to assign special values automatically to your fields. As this parameter can be build with a calculation, you can query variables or other tables for information you want to log. With plugin version 7.2 and newer this works for number fields in addition to text fields.
Table names are case sensitive. If you change case of a table name, the fields may be logged again.
With plugin version 4.4 you can use * on the end of the name to match all names starting with same text.
Indexes in the AuditLog table help to speedup the queries internally made by plugin. Especially indexes for the fields FieldHash, FieldName, RecordID and TableName.
Version 8.5 can use either FieldName or FieldID in AuditLog table to identify the field. For the value we prefer to use FieldHash, but if you have no such field, we use FieldValue. AuditLog field list is now queried via SQL instead of using a layout. So with version 8.5 the AuditLog layout is optional.
Log record on changes:
Log record on changes except fields fullname and zipCity:
Log change and pass value for custom log field "InsideScript" with value of variable:
Log changes and pass custom GUID field while also checking a global variable to disable auditing for batch imports:
Run Audit.Changed with list of fields in a global field in the table:
Run Audit with GetFieldName with v8.3 or newer:
Created 18th August 2014, last changed 27th October 2018
Feedback: Report problem or ask question.
MBS Xojo Chart Plugins