Using the SOQL Sync Down Target

If you can define a SOQL query that selects everything required for a business need, the SOQL target is your simplest sync down option. This target takes a SOQL query and optional supporting arguments.

Mobile Sync wraps the SOQL query you provide as a REST request and sends it to Salesforce.

Configuration File Usage

For the "target" property, specify the following values.

Target Properties
"type":"soql"
"query": <string>
The SOQL query.
"idFieldName": <string>
(Optional) Name of a custom ID field. If you provide "idFieldName", Mobile Sync uses the field with the given name to get the ID of the record. For example, if you specify "idFieldName":"AcmeId", Mobile Sync obtains the record’s ID from the AcmeId field instead of the default Id field.
"modificationDateFieldName": <string>
(Optional) Name of the field containing the last modification date for the record. If you provide modificationDateFieldName, Mobile Sync uses the field with this name to compute the maxTimestamp value that startFetch uses to resync the records. Default field name is lastModifiedDate.
"maxBatchSize": <integer>
(Optional) Proposed number of records to obtain in each fetch operation. If you provide a maxBatchSize value, Mobile Sync uses it to suggest the maximum number of records to be returned by each fetch operation. The actual number of records fetched can be more or less than the given value. Actual runtime batch sizes can depend on performance concerns, number of matching records, or a LIMIT specified in the query.

iOS APIs

Swift
Class: SoqlSyncDownTarget
1SoqlSyncDownTarget.newSyncTarget(_ query:String) → Self
1SoqlSyncDownTarget.newSyncTarget(_ query:String, maxBatchSize size:Int) → Self
Objective-C
Class: SFSoqlSyncDownTarget
1+ (SFSoqlSyncDownTarget*) newSyncTarget:(NSString*)query;
2+ (SFSoqlSyncDownTarget*) newSyncTarget:(NSString*)query 
3    maxBatchSize:(NSInteger) maxBatchSize;

Android APIs

Kotlin
Class: SoqlSyncDownTarget
1public fun SoqlSyncDownTarget(query: String)
2public fun SoqlSyncDownTarget(idFieldName: String, modificationDateFieldName: String, 
3    query: String)
4public fun SoqlSyncDownTarget(idFieldName: String, modificationDateFieldName: String, 
5    query: String, maxBatchSize: int)
No content provided
Java
Class: SoqlSyncDownTarget
1public SoqlSyncDownTarget(String idFieldName, String modificationDateFieldName, 
2    String query)
3public SoqlSyncDownTarget(String idFieldName, String modificationDateFieldName, 
4    String query, int maxBatchSize)

Example

1{
2  "syncs": [
3    {
4      "syncName": "syncDownContacts",
5      "syncType": "syncDown",
6      "soupName": "contacts",
7      "target": {"type":"soql", "query":"SELECT FirstName, LastName, Title, 
8           MobilePhone, Email, Department, HomePhone FROM Contact LIMIT 10000", 
9           "maxBatchSize":500},
10      "options": {"mergeMode":"OVERWRITE"}
11    },
12    {
13      "syncName": "syncUpContacts",
14      "syncType": "syncUp",
15      "soupName": "contacts",
16      "target": {"createFieldlist":["FirstName", "LastName", "Title", "MobilePhone", 
17          "Email", "Department", "HomePhone"]},
18      "options": {"fieldlist":["Id", "FirstName", "LastName", "Title", "MobilePhone", 
19          "Email", "Department", "HomePhone"], "mergeMode":"LEAVE_IF_CHANGED"}
20    }
21  ]
22}