- 01 Aug 2024
- 2 Minutes to read
- Print
- DarkLight
Using SOQL With Salesforce
- Updated on 01 Aug 2024
- 2 Minutes to read
- Print
- DarkLight
Overview
The steps provided in the Salesforce Module do not accommodate all Salesforce data types or custom data types introduced by a company into a Salesforce environment. These types can be found using the SOAP version of the API or the Advanced Salesforce steps in the Toolbox. Salesforce uses a SQL-like query language called SOQL to query objects. There are two steps that allow a user to run queries of objects.
- Run SOQLQuery - this step allows a user to run a query that does not necessarily return data.
- Run SOQLQuery Get Json - runs a query and gives the user a result in JSON that can be manipulated using steps under Data > JSON in the Flow.
- Existing Salesforce Account.
- Access to Salesforce API.
- Installation and set up of Salesforce Module in Decisions. To learn how to install a module, see Installing Modules.
SOQL
To learn more about SOQL or to refine queries, login to Salesforce and use the Developer Console. This is the best environment for tuning the queries needed to make a Flow work with Salesforce. This allows a user to be able to paste these queries into Flow steps and substitute the variables to make them dynamic.
Example
The following example will demonstrate how to run a SOQL Query that returns JSON data and deserializes the data.
- In a Designer Project, click CREATE FLOW on the Global Action Bar. Name the Flow and click CREATE FLOW.
- Click the Done path on the Start step and navigate to Integrations > Salesforce > Advanced. Select the Run SOQL Query Get Json step and click ADD.
- Under the INPUTS category on the Properties panel, select Unknown next to Soql Query field and click Merge Plain Text. Click SHOW EDITOR.If using a value with escape characters, use the Get SOQL Escaped String step before a Run SOQL Query step to format the value and input it into the SOQL Query through the Merge Text Editor.
- In the Merge Text Editor window, enter a SOQL query to use. After inputting the query, click SAVE to close the window.
- Select Unknown next to Token Id and select Constant. Click the dropdown list and select the appropriate token.
- Click the Done path and navigate to All Steps [Catalog] > Data > JSON. Select the Json Deserialize step and click ADD.
- Under PARAMETERS, click the dropdown under JSON Type and select an appropriate JSON Type.
- Under the INPUTS category, select Unknown next to the String to Deserialize field and click Select From Flow. Select Run SOQLQuery Get Json_ Output and click DONE.
- Connect the Done and Error path to the End step. Click Save to save changes.
Debug
- On the top action bar, click Debug. Then, click START DEBUGGING.
- Select the Json Deserialize step, select Execution 1, and click View Input/Output Data.