Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 9.3   9.4   9.5   10.0   10.1   10.2   10.3   10.4   10.5   10.6    Statistic    FMM    Blog  

FM.UpdateRecord

Update an existing record in a table in one line.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
FM FMSQL 6.0 Yes Yes Yes Yes Yes
MBS( "FM.UpdateRecord"; FileName; TableName; IDField; IDValue; FieldName; FieldValue )   More

Parameters

Parameter Description Example
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 insert record into.
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 field which provides an unique ID for each record, so we can identify the field.
Can be RecordID for the record ID.

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 ID field to identify the record.
Data type of parameter must match the data type of the field.
$RecordID
FieldName A field name to set.
Can be ID of field, so we lookup name by ID.
Can be result of GetFieldName() function as we remove table name automatically.
"Model"
FieldValue A field value to use for setting the field in the parameter before.
Data type of parameter must match the data type of the field.
"Test"

Result

Returns OK or error.

Description

Update 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.
Then you pass one pair of field name and value for each field you like to set in the new record.

Please note that FM.UpdateRecord and FM.UpdateRecords are nearly identical. Just FM.UpdateRecord provides the check to make sure only one record matches while FM.UpdateRecords allows several records to be updated. So with FM.UpdateRecords 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. Table IDs and table names must be unique across all open files for this to work correctly.

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.

Examples

Update a record:

MBS( "FM.UpdateRecord";
""; "Asset Management"; /* file and table name */
"Asset ID"; "1"; /* ID field and value */
"Information"; "Just a test"; /* first field and value */
"Category"; "BestItems" ) /* second field and value */

Update a record:

MBS( "FM.UpdateRecord"; Get(FileName); "Kontakte"; "Vorname"; "Joe"; "Firma"; "Test" )

Update a repeating field:

Set Variable [ $r ; Value: MBS( "FM.UpdateRecord"; ""; "Contacts"; "RowID"; 1; "repeating[5]"; "Hello" ) ]
Show Custom Dialog [ Get ( RecordID ) & ": " & Contacts::repeating[5] ]

See also

Example Databases

Blog Entries

FileMaker Magazin

Release notes

Created 5th December 2015, last changed 17th January 2020


FM.TableStatistics   -   FM.UpdateRecord2

Feedback: Report problem or ask question.




Links
MBS Xojo Plugins