Audit.Delete
------------

Log record deletion.

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

MBS( "Audit.Delete"; TimeStamp; TableName { ; FieldsToIgnore...; ExtraFields... } ) 

**MBS**( **"Audit.Delete";** /\* Log record deletion. \*/  
**$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" \*/   
**$FieldsToIgnore...**; /\* Optional; A list of field names to ignore.   
Global fields and those set with [Audit.SetIgnoredFieldNames](AuditSetIgnoredFieldNames.md) are always ignored.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" |  |
| FieldsToIgnore... | A list of field names to ignore.    Global fields and those set with [Audit.SetIgnoredFieldNames](AuditSetIgnoredFieldNames.md) are always ignored. | "myField" | Optional |
| 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

Log record deletion.  
In order to log record deletion, please go to "Manage Accounts &amp; Privileges" dialog in FileMaker. Check the Privileges Sets tab and create a new custom privilege set. You can duplicate one of the existing ones like the "Data Entry Only" set. Edit the new privilege set and select for Records the custom privileges option in the popup menu. For the custom record privileges, you choose for delete the limited option in the popup menu. Now in the specify calculation dialog, you enter the function: MBS( "Audit.Delete" ). Done for this table. Repeat for other tables and for other privilege sets you need.  
The plugin will analyze the record on deletion now and write down values to AuditLog table with Create/Changed entries if the record was not yet analyzed or not completely analyzed so far. Finally for a delete operation, it logs a delete entry.  
  
In the fields to ignore parameters you can pass also "FieldName|Value" to assign special values automatically. As this parameter can be build with a calculation, you can query variables or other tables for information you want to log.  
  
You can call [Audit.SetIgnoredFieldNames](AuditSetIgnoredFieldNames.md) in order to have the plugin ignore some fields. Or pass the field names to this function.  
  
Be aware that even if you call this function from the calculation in privileges the deletion may be cancelled later and you have deleted logged, but not executed. You can work around by implementing your own dialog for user to cancel.  
  
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.   
  
The [audit](component_Audit.md) functions relay on the permissions to make SQL queries on your tables.  
  
To install the expression, you do:  
- Go to Manage Security Dialog
- Click Privilege Sets tab
- Edit a privilege set
- Pick "Custom privileges..." in the popup for Records.
- For each table there click the entry
- and below in popup for Delete pick "limited..."
- put in the calculation, e.g. MBS( "Audit.Delete"; AuditTimeStamp; "YourTableName" ) with the correct table name.

This function takes variable number of parameters. Pass as much parameters as needed separated by the semicolon in FileMaker.  
Please repeat FieldsToIgnore and ExtraFields parameters as often as you need.  
### Examples

Log record on delete:

 MBS ( "Audit.Delete"; MyTable::AuditTimeStamp ; "MyTable" )  
Run delete and set a custom field with a special value:

 MBS ("Audit.Delete"; Audit::AuditTimeStamp ; "MyTable"; "CurrentTaskID|" &amp; $$CurrentTaskID )  
### See also

- [Audit.Delete2](AuditDelete2.md)
- [Audit.SetEnabled](AuditSetEnabled.md)
- [Audit.SetIgnoredFieldNames](AuditSetIgnoredFieldNames.md)

### Release notes

- **Version 13.2**
    - Changed [Audit.Delete](https://www.mbsplugins.eu/AuditDelete.shtml) and [Audit.Delete2](https://www.mbsplugins.eu/AuditDelete2.shtml) to record new fields found before deleting with Delete instead of Create.
- **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.

### Blog Entries

- [MBS FileMaker Plugin, version 13.2pr2](https://www.mbsplugins.de/archive/2023-04-13/MBS_FileMaker_Plugin_version_1/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)
- [Audit with MBS FileMaker Plugin](https://www.mbsplugins.de/archive/2017-01-07/Audit_with_MBS_FileMaker_Plugi/monkeybreadsoftware_blog_filemaker)
- [Introducing Audit Plugin Functions for Filemaker](https://www.mbsplugins.de/archive/2012-08-01/Introducing_Audit_Plugin_Funct/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

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

This function checks for a license.

Created 18th August 2014 , last changed 29th September 2023

  
[Audit.ClearCaches](AuditClearCaches.md) - [Audit.Delete2](AuditDelete2.md)

[HTML Version](AuditDelete.shtml)