Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
FM.InsertRecordTSV
Inserts records based on tab/return separated text.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
FM FMSQL | 5.3 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
MBS( "FM.InsertRecordTSV"; InsertFileName; InsertTableName; FieldNames; Text { ; FieldName...; FieldValue... } ) More
Parameters
Parameter | Description | Example | Flags |
---|---|---|---|
InsertFileName | The file name of where the insert table is inside. Can be empty to look for the table in all files. | Get(FileName) | |
InsertTableName | 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" | |
FieldNames | A list of field names for the insert. Empty entries in the list are ignored. Can be ID of field, so we lookup name by ID. Can be result of GetFieldName() function as we remove table name automatically. |
"Model" | |
Text | The text to import in TSV format. This means tab character between fields and newline character for new records | "Bob Miller 12345 New York" | |
FieldName... | Additional field to set with the import. Can be ID of field, so we lookup name by ID. Can be result of GetFieldName() function as we remove table name automatically. |
"Model" | Optional |
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" | Optional |
Result
Returns number or error.
Description
Inserts records based on tab/return separated text.This function allows for easy importing of text to create a lot of records.
Filename parameters can be empty.
Use FM.ExecuteSQL.LastErrorMessage and FM.ExecuteSQL.LastError to see error message.
Reports an error if field name list doesn't match column count of the query result. Since version 8.2 we can fill text, number, time, timestamp and date fields and let FileMaker convert the values with your current locale.
Returns number of records added.
For XML, please check XML.Import function. For splitting values with delimiter into a list, please use QuickList.New which also works with comma, tab, newline or other characters.
With plugin version 6.2 or newer you can pass one pair of field name and value for each extra field you like to set in the new records. e.g. a reference 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.
Version 11.1 does handle backslashes inside quotes for \r and \n for returns and \t for tabs. You can use \\ for backslash.
This function uses our field type cache from the Audit functions to determinate the type of a field. If you change a field type, you may restart FileMaker or use Audit.ClearCaches to clear it.
This function takes variable number of parameters. Pass as much parameters as needed separated by the semicolon in FileMaker.
Please repeat FieldName and FieldValue parameters as often as you need.
Examples
Import records from text:
Delete All Records [No dialog]
Set Variable [$fields; Value:"FirstName¶LastName¶City"]
Set Variable [$r; Value:MBS("FM.InsertRecordTSV"; ""; "Contacts"; $fields; Import::ImportText)]
Import some contacts with passing import ID/timestamp:
MBS( "FM.InsertRecordTSV"; "Contacts.fmp12"; "Contacts"; "FirstName¶LastName¶City"; $tsv; "ImportID"; $importID; "ImportDate"; Get(CurrentHostTimeStamp))
See also
- Audit.ClearCaches
- FM.ExecuteSQL
- FM.ExecuteSQL.LastError
- FM.InsertRecord
- FM.InsertRecordCSV
- FM.InsertRecordQuery
- FM.InsertSetUpdateProgressDialog
- QuickList.New
- XML.Import
- XML.InsertRecords
Release notes
- Version 11.2
- Changed FM.InsertRecordCSV and FM.InsertRecordTSV to recognize backslash escapes to have returns and tabs escaped in text.
- Version 8.2
- Improved FM.InsertRecordCSV and FM.InsertRecordTSV to handle date/time/timestamp fields.
- Version 8.0
- Changed FM.InsertRecordCSV and FM.InsertRecordTSV to detect whether columns are numbers instead of text and handle it correctly.
Example Databases
Blog Entries
- MBS FileMaker Plugin, version 11.2pr5
- MBS FileMaker Plugin, version 8.2pr1
- MBS FileMaker Plugin, version 7.6pr5
- MBS FileMaker Plugin, version 6.2pr5
- MBS FileMaker Plugin, version 6.2pr3
- [ANN] MBS FileMaker Plugin 5.3 for OS X/Windows
- MBS FileMaker Plugin, version 5.3pr3
- XML Import for FileMaker
- New today: FM.InsertRecordTSV
FileMaker Magazin
This function checks for a license.
Created 8th September 2015, last changed 29th January 2023
FM.InsertRecordQueryIgnoreDuplicates - FM.InsertSetUpdateProgressDialog