Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

JSON.Import.Work

Performs import.

Component Version macOS Windows Linux Server iOS SDK
JSON 5.4 ✅ 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 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 and FM.ExecuteSQL.LastSQL 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") ]
    Set Variable [ $s ; Value: MBS("JSON.Import.Status") ]
    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 > 100 ]
End Loop

See also

Example Databases

Blog Entries

This function is free to use.

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


JSON.Import.Total - JSON.IsValid