Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
FM.DeleteRecord
Deletes an existing record in a table in one line.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
FM FMSQL | 6.0 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
MBS( "FM.DeleteRecord"; FileName; TableName; IDField; IDValue { ; IDField2; IDValue2; IDField3; IDValue3 } ) More
Parameters
Parameter | Description | Example | Flags |
---|---|---|---|
FileName | The file name of where the table is inside. Can be empty to look for the table in all files. | Get(FileName) | |
TableName | The name of the table to delete record from. Can be ID of table, so we lookup name by ID. Can be result of GetFieldName() function as we remove field name automatically. |
"Assets" | |
IDField | The name of the first field which provides an unique ID for each record, so we can identify the field. Can be ID of field, so we lookup name by ID. Can be result of GetFieldName() function as we remove table name automatically. |
"ID" | |
IDValue | The value for the first ID field to identify the record. Data type of parameter must match the data type of the field. |
$RecordID | |
IDField2 | Available in MBS FileMaker Plugin 8.2 or newer. The name of the second field which provides an unique ID for each record, so we can identify the field. Can be ID of field, so we lookup name by ID. Can be result of GetFieldName() function as we remove table name automatically. |
"PersonID" | Optional |
IDValue2 | Available in MBS FileMaker Plugin 8.2 or newer. The value for second ID field to identify the record. Data type of parameter must match the data type of the field. |
$PersonID | Optional |
IDField3 | Available in MBS FileMaker Plugin 8.2 or newer. The name of the third field which provides an unique ID for each record, so we can identify the field. Can be ID of field, so we lookup name by ID. Can be result of GetFieldName() function as we remove table name automatically. |
"CompanyID" | Optional |
IDValue3 | Available in MBS FileMaker Plugin 8.2 or newer. The value for third ID field to identify the record. Data type of parameter must match the data type of the field. |
$CompanyID | Optional |
Result
Returns OK or error.
Description
Deletes an existing record in a table in one line.You pass to this function table name (and optional filename).
To identify the record you pass the name of the ID field and the value for the record. The ID field must be unique.
Please note that FM.DeleteRecord and FM.DeleteRecords are nearly identical. Just FM.DeleteRecord provides the check to make sure only one record matches while FM.DeleteRecords allows several records to be deleted. So with FM.DeleteRecords you can easily erase a lot of data if you pass wrong ID!
With plugin version 7.2 or later, you can specify fields and table via IDs and the plugin will lookup them for you at runtime.
Version 8.2 allows to specify up to 3 ID parameters.
With plugin version 8.4 or newer, you can use GetFieldName() function to query field names and the plugin removes the table prefix with :: in the field name before passing it to SQL engine.
You can use FM.ExecuteSQL.LastSQL function to see later what SQL was created and run.
The SQL functions in FileMaker do not trigger OnWindowsTransaction script trigger.
Examples
Delete a record based on values:
Set Variable [ $r ; Value: MBS( "FM.DeleteRecord"; Get(FileName); "Contacts"; "First"; "Christian"; "Last"; "Schmitz"; "Company"; "Test Inc.") ]
See also
- FM.DeleteRecords
- FM.ExecuteSQL
- FM.ExecuteSQL.LastSQL
- FM.UpdateRecord
- JSON.DeleteRecord
- JSON.DeleteRecords
Release notes
- Version 14.0
- Changed FM.DeleteRecords to return OK if no record was found.
- Version 10.1
- Changed FM.InsertRecord, FM.CompareTables, FM.DeleteRecord, FM.DeleteRecords, FM.InsertOrUpdateRecord and FM.UpdateRecord to take table name from first field name if table name is empty.
- Version 8.2
- Upgraded FM.DeleteRecord and FM.DeleteRecords to accept 1 to 3 ID values.
Blog Entries
- Insert or update with JSON
- MBS FileMaker Plugin, version 14.4pr4
- New records without layout change in FileMaker
- MBS @ FMTraining.TV
- MBS FileMaker Plugin, version 10.1pr1
- MBS FileMaker Plugin, version 8.2pr1
- MBS FileMaker Plugin 6.0 for OS X/Windows
- MBS FileMaker Plugin, version 5.5pr3
FileMaker Magazin
This function is free to use.
Created 11st December 2015, last changed 29th February 2024