1

Below is my code for creating the soup on locally and sync down and store the data in local soup. Below is my code calling onCreate method. Salesforce data is not syncdown. Can anyone help me for this issue.

private void createSoup() {


    IndexSpec[] TMACCOUNTS_INDEX_SPEC = {

            new IndexSpec("product_amount",    SmartStore.Type.floating),
            new IndexSpec("tm_type",      SmartStore.Type.full_text),
            new IndexSpec("Date", SmartStore.Type.full_text),
            new IndexSpec("tm_phone", SmartStore.Type.full_text),
            new IndexSpec("Id",      SmartStore.Type.integer),
            new IndexSpec("OwnerId", SmartStore.Type.string),
            new IndexSpec("User_Name", SmartStore.Type.string)
    };
    mSmartStore.registerSoup(SoupName.TMACCOUNT_SOUP, TMACCOUNTS_INDEX_SPEC);

}



private void syncDownTMAccount() {

    List<String> accountObject =  new ArrayList<>();
    accountObject.add("product_amount");
    accountObject.add("tm_type");
    accountObject.add("Date");
    accountObject.add("tm_phone");

    final SyncOptions options = SyncOptions.optionsForSyncUp(accountObject, SyncState.MergeMode.LEAVE_IF_CHANGED);

    SyncDownTarget target = new SoqlSyncDownTarget("SELECT  product_amount__c, tm_type__c, Date__c, tm_phone__c FROM "+SoupName.TMACCOUNT_SOUP__);

    try {

        DebugLog.d("SyncDownTarget=="+target.asJSON());

       /* syncManager.syncUp(target, options, SoupName.TMACCOUNT_SOUP, new SyncManager.SyncUpdateCallback() {
                    @Override
                    public void onUpdate(SyncState sync) {
                        handleSyncUpdate(sync);
                    }
                });

                JSONArray result = null;
                try {
                    result = mSmartStore.query(QuerySpec.buildSmartQuerySpec("select product_amount__c from {"+ SoupName.TMACCOUNT_SOUP+"}", 10), 0);
                } catch (JSONException e) {
                    e.printStackTrace();
                }

                DebugLog.d("Local DB data= "+result);*/

            }
        });

    } catch (JSONException e) {
        Log.e(TAG, "JSONException occurred while parsing", e);
    }
}

Your Answer

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

Browse other questions tagged or ask your own question.