JSON.UpdateRecords
------------------

Updates existing records in a table in one line using JSON.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [JSON](component_JSON.md) | [14.4](newinversion144.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "JSON.UpdateRecords"; FileName; TableName; PrimaryKeys; JSON ) 

**MBS**( **"JSON.UpdateRecords";** /\* Updates existing records in a table in one line using JSON. \*/  
**$FileName**; /\* The file name of where the table is inside. Can be empty to look for the table in all files.e.g. 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.e.g. "Assets" \*/   
**$PrimaryKeys**; /\* The JSON with keys and values which provides an unique ID for each record, so we can identify the field.  
Can be ROWID for the record ID.  
  
Field name can be the result of GetFieldName() function as we remove table name automatically. If field name is a number with field ID, so we lookup name by ID.e.g. "ID" \*/   
**$JSON**) /\* The JSON object with the record. \*/ 

### 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" |
| PrimaryKeys | The JSON with keys and values which provides an unique ID for each record, so we can identify the field.   Can be ROWID for the record ID.      Field name can be the result of GetFieldName() function as we remove table name automatically. If field name is a number with field ID, so we lookup name by ID. | "ID" |
| JSON | The JSON object with the record. |  |

### Result

Returns OK or error.

### Description

Updates existing records in a table in one line using JSON.  
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 not be unique, so several records can be updated at once.  
Then you pass one pair of field name and value for each field you like to set in the new record.  
  
Please note that [JSON.UpdateRecord](JSONUpdateRecord.md) and JSON.UpdateRecords are nearly identical. Just [JSON.UpdateRecord](JSONUpdateRecord.md) provides the check to make sure only one record matches while JSON.UpdateRecords allows several records to be updated. So with JSON.UpdateRecords you can easily erase a lot of data if you pass wrong ID!  
  
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.  
  
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](FMExecuteSQLLastSQL.md) function to see later what SQL was created and run.  
### Examples

Find records with matching first name and update to new last name:

 Set Variable \[ $r ; Value:MBS ("JSON.UpdateRecords"; ""; "Contacts"; "{\\"First Name\\": \\"Joe\\"}"; "{\\"Last Name\\": \\"Miller\\"}") \]  
If \[ MBS ("IsError") \]  
 Show Custom Dialog \[ Title: "Failed to update."; Message: $r ; Default Button: “OK”, Commit: “Yes” \]  
End If  
Find records with matching first names and update to new last name:

 Set Variable \[ $r ; Value:MBS ("JSON.UpdateRecords"; ""; "Contacts"; "{\\"First Name\\": \[\\"Joe\\", \\"Bob\\"\]}"; "{\\"Last Name\\": \\"Miller\\"}") \]  
If \[ MBS ("IsError") \]  
 Show Custom Dialog \[ Title: "Failed to update."; Message: $r ; Default Button: “OK”, Commit: “Yes” \]  
End If  
### See also

- [FM.UpdateRecord](FMUpdateRecord.md)
- [FM.UpdateRecord3](FMUpdateRecord3.md)
- [FM.UpdateRecord4](FMUpdateRecord4.md)
- [FM.UpdateRecord5](FMUpdateRecord5.md)
- [FM.UpdateRecords](FMUpdateRecords.md)
- [FM.UpdateRecords3](FMUpdateRecords3.md)
- [FM.UpdateRecords4](FMUpdateRecords4.md)
- [IsError](IsError.md)
- [JSON.DeleteRecords](JSONDeleteRecords.md)
- [JSON.UpdateRecord](JSONUpdateRecord.md)

### Release notes

- **Version 15.3**
    - Enhanced [JSON.UpdateRecords](https://www.mbsplugins.eu/JSONUpdateRecords.shtml) to take keys as JSON array, so you can update multiple records with different primary keys.
- **Version 14.4**
    - Added [JSON.UpdateRecord](https://www.mbsplugins.eu/JSONUpdateRecord.shtml) and [JSON.UpdateRecords](https://www.mbsplugins.eu/JSONUpdateRecords.shtml) functions.

### Example Databases

- [JSON/JSON Insert and Update](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/JSON/JSON%20Insert%20and%20Update.shtml#5ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 15.3pr1](https://www.mbsplugins.de/archive/2025-06-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [New in MBS FileMaker Plugin 14.4](https://www.mbsplugins.de/archive/2024-09-24/New_in_MBS_FileMaker_Plugin_14/monkeybreadsoftware_blog_filemaker)
- [Neues MBS Plugin 14.4 für Claris FileMaker](https://www.mbsplugins.de/archive/2024-09-17/Neues_MBS_Plugin_144_für_Clar/monkeybreadsoftware_blog_filemaker)
- [MBS Plugin 14.4 for Claris FileMaker](https://www.mbsplugins.de/archive/2024-09-17/MBS_Plugin_144_for_Claris_File/monkeybreadsoftware_blog_filemaker)
- [Insert or update with JSON](https://www.mbsplugins.de/archive/2024-08-28/Insert_or_update_with_JSON/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 14.4pr4](https://www.mbsplugins.de/archive/2024-08-26/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 14.4pr3](https://www.mbsplugins.de/archive/2024-08-21/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 20th August 2024 , last changed 20th May 2025

  
[JSON.UpdateRecord](JSONUpdateRecord.md) - [Java.CallObjectMethod](JavaCallObjectMethod.md)

[HTML Version](JSONUpdateRecords.shtml)