Audit.Changed2
--------------

Same as [Audit.Changed](AuditChanged.md), but here you pass the list of fields to check.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Audit](component_Audit.md) | [3.1](newinversion31.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Audit.Changed2"; TimeStamp; TableName; FieldsToCheck... { ; ExtraFields... } ) 

**MBS**( **"Audit.Changed2";** /\* Same as Audit.Changed, but here you pass the list of fields to check. \*/  
**$TimeStamp**; /\* Pass here the timestamp field you added for auditing to the table.  
This field is passed here to trigger the calculation, but the value is not used. Must be a timestamp.e.g. AuditTimeStamp \*/   
**$TableName**; /\* The name of the table.  
Or the table occurrence if needed.  
  
With 10.2 optionally as second value the name of the audit log table unless you take the default AuditLog.e.g. "Firma¶MyAuditLog" \*/   
**$FieldsToCheck...**; /\* A list of field names to check.e.g. "myField" \*/   
**$ExtraFields...**) /\* Optional; Custom fields to set.  
Pass in field name followed by "|" character and a value.  
Field type can be text or number.e.g. "ScriptName|" &amp; $ScriptName \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| TimeStamp | Pass here the timestamp field you added for auditing to the table.   This field is passed here to trigger the calculation, but the value is not used. Must be a timestamp. | AuditTimeStamp |  |
| TableName | The name of the table.   Or the table occurrence if needed.      With 10.2 optionally as second value the name of the audit log table unless you take the default AuditLog. | "Firma¶MyAuditLog" |  |
| FieldsToCheck... | A list of field names to check. | "myField" |  |
| ExtraFields... | Custom fields to set.   Pass in field name followed by "\|" character and a value.   Field type can be text or number. | "ScriptName\|" &amp; $ScriptName | Optional |

### Result

Returns 1.

### Description

Same as [Audit.Changed](AuditChanged.md), but here you pass the list of fields to check.  
The Audit.Changed2 function with passing field list is quicker than the [Audit.Changed](AuditChanged.md) function as we skip querying the field list from FileMaker.  
  
This function takes variable number of parameters. Pass as much parameters as needed separated by the semicolon in FileMaker.  
Please repeat FieldsToCheck and ExtraFields parameters as often as you need.  
### Examples

Log record on changes:

 MBS ( "Audit.Changed2"; MyTable::AuditTimeStamp ; "MyTable"; "firstName"; "lastName"; "age" )  
Run Audit.Changed2 with list of fields in a global field in the table:

 Evaluate("MBS (\\"Audit.Changed2\\"; GetAsTimeStamp(\\"" &amp; Events::AuditTimeStamp &amp; "\\"); \\"Events\\"; \\"" &amp; Substitute(Events::AuditFields ; "¶"; "\\"; \\"") &amp; "\\")")  
Run Audit with GetFieldName with v8.3 or newer:

 MBS ("Audit.Changed2"; // call with positive list  
AuditTimeStamp; // the timestamp field to trigger this  
"Audit"; // the name of table  
GetFieldName ( SomeText); // the fields to check  
GetFieldName ( SomeNumber);   
GetFieldName ( SomeTime);   
GetFieldName ( SomeTimeStamp);   
GetFieldName ( SomeContainer);   
"InsideScript|" &amp; $$InsideScript ) // and we pass an extra field with global variable  
Do Audit and set custom TransactionUUID field with UUID:

 MBS ( "Audit.Changed2"; MyTable::AuditTimeStamp ; "MyTable"; "firstName"; "lastName"; "age"; "TransactionUUID|" &amp; Get(UUID) )  
### See also

- [Audit.Backup2](AuditBackup2.md)
- [Audit.Changed](AuditChanged.md)
- [Audit.SetEnabled](AuditSetEnabled.md)
- [Audit.SetIgnoredFieldNames](AuditSetIgnoredFieldNames.md)
- [Audit.Statistics](AuditStatistics.md)

### Release notes

- **Version 10.4**
    - Fixed a crash in [Audit](https://www.mbsplugins.eu/component_Audit.shtml) functions when querying GetFieldID internally. Affects [Audit.Backup](https://www.mbsplugins.eu/AuditBackup.shtml), [Audit.Backup2](https://www.mbsplugins.eu/AuditBackup2.shtml), [Audit.Changed](https://www.mbsplugins.eu/AuditChanged.shtml), [Audit.Changed2](https://www.mbsplugins.eu/AuditChanged2.shtml), [Audit.Delete](https://www.mbsplugins.eu/AuditDelete.shtml) and [Audit.Delete2](https://www.mbsplugins.eu/AuditDelete2.shtml) functions.
- **Version 10.2**
    - For [Audit.Changed](https://www.mbsplugins.eu/AuditChanged.shtml) and [Audit.Changed2](https://www.mbsplugins.eu/AuditChanged2.shtml) you can now customize AuditLog table name. The table name parameter can be a list and include first the table name for the table to check and second the name of the audit table name. If second is empty, we default to AuditLog.

### Example Databases

- [Audit/Event Management with Audit/Event Management with Audit](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Audit/Event%20Management%20with%20Audit/Event%20Management%20with%20Audit.shtml#12953FieldAnchor_)

### Blog Entries

- [Perform Script on Server with Audit for FileMaker Go](https://www.mbsplugins.de/archive/2020-08-18/Perform_Script_on_Server_with_/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 10.4pr1](https://www.mbsplugins.de/archive/2020-07-28/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 10.2pr2](https://www.mbsplugins.de/archive/2020-04-06/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Audit with MBS FileMaker Plugin](https://www.mbsplugins.de/archive/2017-01-07/Audit_with_MBS_FileMaker_Plugi/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 4/2017, Seite 40 bis 41](https://filemaker-magazin.de/neuigkeit/3946-Appetithappen-FMM_201704)

This function checks for a license.

Created 18th August 2014 , last changed 12nd May 2023

  
[Audit.Changed](AuditChanged.md) - [Audit.ClearCaches](AuditClearCaches.md)

[HTML Version](AuditChanged2.shtml)