Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Contents
maxLevel3
typeflat

...

Overview

The following operations allow you to work with queries. Click an operation name to see details on how to use it.

For a sample proxy service that illustrates how to work with queries, see Sample configuration

To retrieve
OperationDescription
Working with QueryTo retrieve
queryRetrieves data from an object.
Working with Query
queryMoreRetrieves additional data if the response is too large.
Working with Query

queryPerformanceFeedback

Use
Uses the query resource along with the explain parameter to get feedback on how Salesforce will execute your query, report, or list view.
Working with QueryFor retrieving
listviewQueryPerformanceFeedbackRetrieves query performance feedback on a report or list view.

Operation details

This section provides further details on the operations related to queries.

Anchor
query
query
Querying records

To retrieve data from an object, use salesforcerest.query and specify the following properties. For more information on how Salesforce queries records, see https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_query.htm

If you want your result results to include deleted records in the Recycle Bin, use salesforcerest.queryAll in place of salesforcerest.query.

Code Block
languagexml
titlequery
<salesforcerest.query>
    <queryString>{$ctx:queryString}</queryString>
</salesforcerest.query>
Properties
  • queryString: The SQL query to use to search for records.
Code Block
languagexml
titlequeryAll
<salesforcerest.query>
    <queryString>{$ctx:queryString}</queryString>
</salesforcerest.query>
Anchor
request
request
Sample request

Following is a sample REST request that can be handled by the query operation. Since this is a combination of two operations, the requests for both are as followsshown below.

Code Block
languagexml
titleSample request for query operation
{
  "accessToken":"00D280000017q6q!AQoAQOeXcp7zKo3gUdy6r064_LsJ5bYYrUn_qAZG9TtKFLPfUMRxiato.E162_2XAtCTZLFQTbNk2Rz6Zm_juSakFE_aaBPp",
  "apiUrl":"https://ap2.salesforce.com",
  "clientId": "3MVG9ZL0ppGP5UrBrnsanGUZRgHqc8gTV4t_6tfuef8Zz4LhFPipmlooU6GBszpplbTzVXXWjqkGHubhRip1s",
  "refreshToken": "5Aep861TSESvWeug_xvFHRBTTbf_YrTWgEyjBJo7Xr34yOQ7GCFUN5DnNPxzDIoGoWi4evqOl_lT1B9nE5dAtSb",
  "clientSecret": "9104967092887676680",
  "hostName": "https://login.salesforce.com",
  "apiVersion": "v32.0",
  "intervalTime" : "100000",
  "queryString": "select id, name from Account",
  "registryPath": "connectors/SalesforceRest"
 }
Code Block
languagexml
titleSample request for queryAll operation
{
  "accessToken":"00D280000017q6q!AQoAQOeXcp7zKo3gUdy6r064_LsJ5bYYrUn_qAZG9TtKFLPfUMRxiato.E162_2XAtCTZLFQTbNk2Rz6Zm_juSakFE_aaBPp",
  "apiUrl":"https://ap2.salesforce.com",
  "clientId": "3MVG9ZL0ppGP5UrBrnsanGUZRgHqc8gTV4t_6tfuef8Zz4LhFPipmlooU6GBszpplbTzVXXWjqkGHubhRip1s",
  "refreshToken": "5Aep861TSESvWeug_xvFHRBTTbf_YrTWgEyjBJo7Xr34yOQ7GCFUN5DnNPxzDIoGoWi4evqOl_lT1B9nE5dAtSb",
  "clientSecret": "9104967092887676680",
  "hostName": "https://login.salesforce.com",
  "apiVersion": "v32.0",
  "intervalTime" : "100000",
  "queryString": "select id, name from Account",
  "registryPath": "connectors/SalesforceRest"
 }
Related Salesforce REST

...

documentation

query: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_query.htm

queryAll: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_query.htm

Anchor
queryMore
queryMore
Querying additional records

If the results from the query or queryAll operations are too large, a the first batch of results are is returned along with an ID that you can use with salesforcerest.queryMore to get additional results. If you want your results to include deleted records in the Recycle Bin, use salesforcerest.queryAllMore in place of salesforcerest.queryMore.

Code Block
languagexml
titlequeryMore
<salesforcerest.queryMore>
    <nextRecordsUrl>{$ctx:nextRecordsUrl}</nextRecordsUrl>
</salesforcerest.queryMore>
Properties
  • nextRecordsUrl: The query identifier for retrieving additional results.
Code Block
languagexml
titlequeryAllMore
<salesforcerest.queryAllMore>
    <nextRecordsUrl>{$ctx:nextRecordsUrl}</nextRecordsUrl>
</salesforcerest.queryAllMore>
Sample request

Following is a sample REST request that can be handled by the queryMore operation. Since this is a combination of two operations, the requests for both are as followsshown below.

Code Block
languagexml
titleSample request for queryMore operation
{
  "accessToken":"00D280000017q6q!AQoAQOeXcp7zKo3gUdy6r064_LsJ5bYYrUn_qAZG9TtKFLPfUMRxiato.E162_2XAtCTZLFQTbNk2Rz6Zm_juSakFE_aaBPp",
  "apiUrl":"https://ap2.salesforce.com",
  "clientId": "3MVG9ZL0ppGP5UrBrnsanGUZRgHqc8gTV4t_6tfuef8Zz4LhFPipmlooU6GBszpplbTzVXXWjqkGHubhRip1s",
  "refreshToken": "5Aep861TSESvWeug_xvFHRBTTbf_YrTWgEyjBJo7Xr34yOQ7GCFUN5DnNPxzDIoGoWi4evqOl_lT1B9nE5dAtSb",
  "clientSecret": "9104967092887676680",
  "hostName": "https://login.salesforce.com",
  "apiVersion": "v32.0",
  "intervalTime" : "100000",
  "nextRecordsUrl": "%s(nextRecordsUrl)",
  "registryPath": "connectors/SalesforceRest"
 }
Code Block
languagexml
titleSample request for queryAllMore operation
{
  "accessToken":"00D280000017q6q!AQoAQOeXcp7zKo3gUdy6r064_LsJ5bYYrUn_qAZG9TtKFLPfUMRxiato.E162_2XAtCTZLFQTbNk2Rz6Zm_juSakFE_aaBPp",
  "apiUrl":"https://ap2.salesforce.com",
  "clientId": "3MVG9ZL0ppGP5UrBrnsanGUZRgHqc8gTV4t_6tfuef8Zz4LhFPipmlooU6GBszpplbTzVXXWjqkGHubhRip1s",
  "refreshToken": "5Aep861TSESvWeug_xvFHRBTTbf_YrTWgEyjBJo7Xr34yOQ7GCFUN5DnNPxzDIoGoWi4evqOl_lT1B9nE5dAtSb",
  "clientSecret": "9104967092887676680",
  "hostName": "https://login.salesforce.com",
  "apiVersion": "v32.0",
  "intervalTime" : "100000",
  "nextRecordsUrl": "%s(nextRecordsUrl)",
  "registryPath": "connectors/SalesforceRest"
 }
Related Salesforce REST

...

documentation

queryMore: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_query.htm

queryAllMore: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_query.htm

Anchor
queryPerformanceFeedback
queryPerformanceFeedback

...

Getting feedback on query performance

To get feedback on how Salesforce will execute your query, use the salesforcerest.queryPerformanceFeedback operation. It uses the Query resource along with the explain parameter to get feedback. Salesforce analyzes each query to find the optimal approach to obtain the query results. Depending on the query and query filters, an index or internal optimization might get be used.

Code Block
languagexml
titlequeryPerformanceFeedback
<salesforcerest.queryPerformanceFeedback>
    <queryString>{$ctx:queryString}</queryString>
</salesforcerest.queryPerformanceFeedback>
Properties
  • queryString: The SQL query to use to get feedback for a query.
Sample request

Following is a sample REST request that can be handled by the queryPerformanceFeedback operation.

Code Block
languagexml
titleSample request for queryPerformanceFeedback operation
{
  "accessToken":"00D280000017q6q!AQoAQOeXcp7zKo3gUdy6r064_LsJ5bYYrUn_qAZG9TtKFLPfUMRxiato.E162_2XAtCTZLFQTbNk2Rz6Zm_juSakFE_aaBPp",
  "apiUrl":"https://ap2.salesforce.com",
  "clientId": "3MVG9ZL0ppGP5UrBrnsanGUZRgHqc8gTV4t_6tfuef8Zz4LhFPipmlooU6GBszpplbTzVXXWjqkGHubhRip1s",
  "refreshToken": "5Aep861TSESvWeug_xvFHRBTTbf_YrTWgEyjBJo7Xr34yOQ7GCFUN5DnNPxzDIoGoWi4evqOl_lT1B9nE5dAtSb",
  "clientSecret": "9104967092887676680",
  "hostName": "https://login.salesforce.com",
  "apiVersion": "v32.0",
  "intervalTime" : "100000",
  "queryString": "select id, name from Account",
  "registryPath": "connectors/SalesforceRest"
 }
Related Salesforce REST

...

documentation

https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_query_explain.htm

Anchor
listviewQueryPerformanceFeedback
listviewQueryPerformanceFeedback

...

Getting feedback on query performance in listview

For retrieving query performance feedback on a report or list view, use salesforcerest.listviewQueryPerformanceFeedback and specify the following properties.

Code Block
languagexml
titlelistviewQueryPerformanceFeedback
<salesforcerest.listviewQueryPerformanceFeedback>
    <listViewID>{$ctx:listViewID}</listViewID>
</salesforcerest.listviewQueryPerformanceFeedback>
Properties
  • listViewID: The ID of the report or list view to get feedback for a query.
Sample request

Following is a sample REST request that can be handled by the listviewQueryPerformanceFeedback operation.

Code Block
languagexml
titleSample request for listviewQueryPerformanceFeedback operation
{
  "accessToken":"00D280000017q6q!AQoAQOeXcp7zKo3gUdy6r064_LsJ5bYYrUn_qAZG9TtKFLPfUMRxiato.E162_2XAtCTZLFQTbNk2Rz6Zm_juSakFE_aaBPp",
  "apiUrl":"https://ap2.salesforce.com",
  "clientId": "3MVG9ZL0ppGP5UrBrnsanGUZRgHqc8gTV4t_6tfuef8Zz4LhFPipmlooU6GBszpplbTzVXXWjqkGHubhRip1s",
  "refreshToken": "5Aep861TSESvWeug_xvFHRBTTbf_YrTWgEyjBJo7Xr34yOQ7GCFUN5DnNPxzDIoGoWi4evqOl_lT1B9nE5dAtSb",
  "clientSecret": "9104967092887676680",
  "hostName": "https://login.salesforce.com",
  "apiVersion": "v32.0",
  "intervalTime" : "100000",
  "listViewID":"00B28000002yqeVEAQ",
  "registryPath": "connectors/SalesforceRest"
 }
Related Salesforce REST

...

documentation

https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_query_explain.htm

Anchor
sample
sample
Sample configuration

Following is a sample proxy service that illustrates how to connect to Salesforce with the init operation and then use the query operation. The sample request for this proxy can be found in the query sample request.

Code Block
languagexml
titleSample Proxy
<proxy xmlns="http://ws.apache.org/ns/synapse" name="query"
       statistics="disable" trace="disable" transports="https http">
    <target>
        <inSequence>
            <property name="accessToken" expression="json-eval($.accessToken)"/>
            <property name="apiUrl" expression="json-eval($.apiUrl)"/>
            <property name="queryString" expression="json-eval($.queryString)"/>
            <property name="clientId" expression="json-eval($.clientId)"/>
            <property name="refreshToken" expression="json-eval($.refreshToken)"/>
            <property name="clientSecret" expression="json-eval($.clientSecret)"/>
            <property name="hostName" expression="json-eval($.hostName)"/>
            <property name="apiVersion" expression="json-eval($.apiVersion)"/>
            <property name="registryPath" expression="json-eval($.registryPath)"/>
			<property name="intervalTime" expression="json-eval($.intervalTime)"/>
            <salesforcerest.init>
                <accessToken>{$ctx:accessToken}</accessToken>
                <apiUrl>{$ctx:apiUrl}</apiUrl>
                <apiVersion>{$ctx:apiVersion}</apiVersion>
                <hostName>{$ctx:hostName}</hostName>
                <clientSecret>{$ctx:clientSecret}</clientSecret>
                <clientId>{$ctx:clientId}</clientId>
                <refreshToken>{$ctx:refreshToken}</refreshToken>
                <registryPath>{$ctx:registryPath}</registryPath>
				<intervalTime>{$ctx:intervalTime}</intervalTime>
            </salesforcerest.init>
            <log category="INFO" level="full" separator=","/>
            <salesforcerest.query>
                <queryString>{$ctx:queryString}</queryString>
            </salesforcerest.query>
            <send/>
        </inSequence>
    </target>
</proxy>