ctm.create

The method of JS Bridge functionality is intended to bulk create records of offline objects:

Query Format

ctm.create([SObject], handler)

SObject is the JS object that indicates the API name of the offline object and a list of fields with values.

Handler

Use a handler function to describe the output format of the query results, e.g., to display the results of operations or method errors for debugging purposes.

ctm.create([{"SObject": "Account", "Name": "Google, Inc"}])
var sObjArray = [];
var sObj = {
SObject: "Account",
Name: "Test Account",
Phone: "123-45-67",
Type: "Prospect"
};
sObjArray.push(sObj);

ctm.create(sObjArray, function(createResponse){
console.log('New record Id', createResponse.result[0].Id);
})
var createString = '[{"SObject":"Account", "Name":"Test Account"}, {"SObject":"Account", "Name":"Sample Account"}]';

var createObject = JSON.parse(createString);

ctm.create(createObject, function(response){
console.log('Create result', response);
})

The result:

{
    "result": [
        {
            "Id": "DSFS-2342-TYRE-ADSFBA374Q8RQ8",
            "Name": "Google, Inc"
        }
    ],
    "success": true,
}
``