1

Recently I started learning mobile SDK and playing around with examples provided with SalesforceMobileSDK for iOS(using hybrid, so HTML + JS. No Objective-C!)

In AccountEditor app I noticed that I can create records offline, then go online and sync it. But the problem is that sync operation runs for each record which is slow(especially if I would have to upsert huge amounts of records).

So my question is:

Is it possible to upsert locally created records in bulk? And if so, how should I approach it?

5

You can do a bulk upsert following the approach listed in this example.

OfflineQueue.StoreRecords = function(records,error){
    console.log('OfflineQueue.storeRecords');

    navigator.smartstore.upsertSoupEntriesWithExternalId('Password__c',records, 'Id', function(){
        console.log("Soup Upsert Success");        
    }, error);


    //if we're not connected, queue the records
    if(!Util.checkConnection()){
        OfflineQueue.QueueRecords(records,error);
    }
}

You can load the records sequentially from the queue and remove them from the queue once they get upserted successfully into Salesforce.

Note that this is an example from an older version of SDK but the approach still works well with the latest Mobile SDK.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.