iOS native app:: When I refresh remote data using SFSyncStateMergeModeOverwrite sync options the records previously downloaded, that have been deleted in Salesforce, are not removed from my local data. What do I need to do to sync the local data with Salesforce, including deleting invalid records?


This question has been answered by Bharath Hariharan in the Mobile SDK community.

Bharath Hariharan

Currently, we don't have a way to determine if a record has been deleted on the server. Hence, the record hangs around in SmartStore.

Arthur Lockrem

What do you suggestion I do if the client wants to get a true sync with Salesforce? Is there a way to completely clear the local data?

Bharath Hariharan Due to server side API limitations to detect deleted records, there are 2 possible ways to solve this:

1) Delete all the local data and re-insert all the new records fetched from salesforce via syncdown. This is very easy to do but works only if the data size is small (few hundred records). But for large datasets, this could be a big performance hit.

2) The other option is to scan the local store and compare the ids from local store and salesforce db. This can support larger datasets but gets more complicated to implement as the data size grows.

Arthur Lockrem That is great advice. Thank you.

Please confirm the SFSmartStore removeEntries:fromSoup: is the proper way to completely clear the local data.

If this is the right method, I assume running this in a loop is the proper way to delete all entries in multiple soups.

Thank you for all of your help.

Bharath Hariharan If you're attempting to remove specific entries, then yes 'SFSmartStore removeEntries:fromSoup:' is the way to go. If you're attempting to remove ALL entries from a soup, 'SFSmartStore clearSoup:' is the way to go.

Read more

Arthur Lockrem Perfect! Thank you again.

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.