如何在Salesforce(MobileSDK android)usersyncs.json目标中动态更改查询

时间:2019-08-19 07:11:50

标签: salesforce salesforce-mobile-sdk

我正在使用Salesforce MobileSDK(android)开发一个Android应用程序。我正在使用Salesforce MobileSDK的SmartStore和SamrtSync框架。我的查询内置在usersysncs.json文件目标中,如下所示

usersyncs.json

{
  "syncName": "syncDownUser",
  "syncType": "syncDown",
  "soupName": "users",
  "target": {"type":"soql", "query":"SELECT Id, Name, AccountId FROM User LIMIT 10000"},
  "options": {"mergeMode":"OVERWRITE"}
},
{
  "syncName": "syncUpUser",
  "syncType": "syncUp",
  "soupName": "users",
  "target": {"createFieldlist":["Name", "AccountId"]},
  "options": {"fieldlist": ["Id", "Name", "AccountId"], "mergeMode":"LEAVE_IF_CHANGED"}
}

问题 如果我的查询是静态查询,则可以直接采用上述方法,但是问题是我的查询是动态查询,即下面的

"SELECT Id, Name, AccountId FROM User WHERE Case__c IN " +"(" + ids + ")"+ " LIMIT 10000"

从我的一种编程逻辑中生成的ID必须附加到查询中。

我已经尝试使用无法正常运行的buildSmartQuerySpec

尝试逻辑

SmartStore smartStore = SmartStoreSDKManager.getInstance().getSmartStore();
String smartSql = "SELECT Id, Name, AccountId FROM User WHERE Case__c IN " +"("+ids+")"+ " LIMIT 10000";

            final QuerySpec querySpec = QuerySpec.buildSmartQuerySpec(smartSql, 100);

            JSONArray results = null;
            List<UserObject> users = new ArrayList<TaskObject>();
            try {
                results = smartStore.query(querySpec, 0);
                for (int i = 0; i < results.length(); i++) {
                    users.add(new TaskObject(results.getJSONObject(i)));
                }
            } catch (JSONException e) {
                Log.e(TAG, "JSONException occurred while parsing", e);
            } catch (SmartSqlException e) {
                Log.e(TAG, "SmartSqlException occurred while fetching data", e);
            }

例外

  

net.sqlcipher.database.SQLiteException:没有这样的表:User:,正在编译:SELECT * FROM(SELECT ID,名称,AccountId来自用户WHERE Case__c IN('500V000000AZgQAIA1')LIMIT 10000)LIMIT 0,100

0 个答案:

没有答案