JSON.Import.Work
----------------

Performs import.

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

MBS( "JSON.Import.Work" ) ### Parameters

none

### Result

Returns OK or error.

### Description

Performs import.  
Normally we do import on idle while a script pause. But on server this does not work.   
You can call this method in a loop to do the inserts for the import.  
But it will not create the tables and fields required for import.  
  
Changed in version 11.3 to use per thread data, so multiple scripts on server can do imports independently. Please make sure you call all [JSON.Import](JSONImport.md) functions on the same script, so they can access their own local dataset and not interfere with other scripts doing imports.  
  
We use SQL to create records, so you can check [FM.ExecuteSQL.LastErrorMessage](FMExecuteSQLLastErrorMessage.md) and [FM.ExecuteSQL.LastSQL](FMExecuteSQLLastSQL.md) after the import for SQL errors.  
### Examples

Sample loop:

 Set Variable \[ $counter ; Value: 0 \]   
Loop  
 If \[ MBS ("IsServer") \]   
 # do some work now  
 Set Variable \[ $r ; Value: MBS ("JSON.Import.Work") \]   
 # let server do indexing  
 Pause/Resume Script \[ Duration (seconds): ,1 \]   
 Else  
 # in FileMaker Pro do it in the pause  
 Pause/Resume Script \[ Duration (seconds): 1 \]   
 End If  
 # and check if we are done  
 Set Variable \[ $todo ; Value: MBS ("[JSON.Import.Todo](JSONImportTodo.md)") \]   
 Set Variable \[ $s ; Value: MBS ("[JSON.Import.Status](JSONImportStatus.md)") \]   
 Exit Loop If \[ $s ≠ "Working" \]   
 # exit after 100 times, which would be about 100000 records.  
 Set Variable \[ $counter ; Value: $counter + 1 \]   
 Exit Loop If \[ $counter &gt; 100 \]   
End Loop  
### See also

- [FM.ExecuteSQL.LastError](FMExecuteSQLLastError.md)
- [FM.ExecuteSQL.LastErrorMessage](FMExecuteSQLLastErrorMessage.md)
- [FM.ExecuteSQL.LastSQL](FMExecuteSQLLastSQL.md)
- [IsServer](IsServer.md)
- [JSON.Import](JSONImport.md)
- [JSON.Import.Errors](JSONImportErrors.md)
- [JSON.Import.Status](JSONImportStatus.md)
- [JSON.Import.Todo](JSONImportTodo.md)
- [JSON.Import.Total](JSONImportTotal.md)
- [XML.Import.Work](XMLImportWork.md)

### Example Databases

- [JSON/JSON Import](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/JSON/JSON%20Import.shtml#2ScriptAnchor_)

### Blog Entries

- [With JSON in excellent form](https://www.mbsplugins.de/archive/2019-11-16/With_JSON_in_excellent_form/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 5.4pr5](https://www.mbsplugins.de/archive/2015-11-10/MBS_FileMaker_Plugin_version_5/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 5/2020, Seite 19](https://filemaker-magazin.de/neuigkeit/4110-Appetithappen-FMM_202005)

This function is free to use.

Created 10th November 2015 , last changed 29th January 2023

  
[JSON.Import.Total](JSONImportTotal.md) - [JSON.InsertOrUpdateRecord](JSONInsertOrUpdateRecord.md)

[HTML Version](JSONImportWork.shtml)