Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Guides   Examples
New in version: 8.0   8.1   8.2   8.3   8.4   8.5   9.0   9.1   9.2   9.3    Statistic  


Inserts a new record in a table in one line.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
FM FMSQL 5.1 Yes Yes Yes Yes Yes
MBS( "FM.InsertRecord"; FileName; TableName; FieldName; FieldValue )   More


Parameter Description Example value
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. "Assets"
FieldName A field name to set. "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.


Returns OK or error.


Inserts a new record in a table in one line.
You pass to this function table name (and optional filename).
Than you pass one pair of field name and value for each field you like to set in the new record.
As we can't know the new ID assigned for the record, you can help yourself by passing in an UUID for a field and later select that to get the auto assigned primary key (or have the UUID be the primary key, so you don't need a query).

See also FM.UpdateRecord to insert new record and FM.InsertOrUpdateRecord to update or insert record.
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.


Insert a record into Assets table:

MBS("FM.InsertRecord"; ""; "Assets"; "Model"; "TestModell"; "Item"; "MyItem"; "Serial Number"; "1234"; "In Service Date"; GetAsDate( "31.05.1996"))

Insert a record with 5 fields:

MBS("FM.InsertRecord"; $filename; $tablename; $field1; $value1; $field2; $value2; $field3; $value3; $field4; $value4; $field5; $value5)

Insert with table and field ID instead of names:

Set Variable [ $r ; Value: MBS("FM.InsertRecord"; Get(FileName); "1065089"; "3"; "Hello") ]

Insert with using GetFieldName for field names:

MBS( "FM.InsertRecord"; ""; "Contacts";
GetFieldName ( Contacts::First ); "Joe";
GetFieldName ( Contacts::Last ); "Miller";
GetFieldName ( Contacts::Group ); "Best Customers" )

See also

Example Databases

Blog Entries

Created 24th April 2015, last changed 31st July 2018

FM.InsertOrUpdateRecordQuery   -   FM.InsertRecordCSV

Feedback: Report problem or ask question.

MBS FileMaker blog