Using SOQL With Salesforce
  • 30 Oct 2023
  • 2 Minutes to read
  • Dark
    Light

Using SOQL With Salesforce

  • Dark
    Light

Article summary

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.
Prerequisities
Before using the Salesforce Module, the following requirements must be met:
  • 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.
The default Salesforce API version is v32.0.

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.

The example below uses a user-defined JSON Type as a parameter. To learn more about creating a JSON Type, see Create Types From JSON Schema.
  1. In a Designer Project, click CREATE FLOW on the Global Action Bar. Name the Flow and click CREATE FLOW.
  2. 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.
  3. 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.


  4. In the Merge Text Editor window, enter a SOQL query to use. After inputting the query, click SAVE to close the window.
  5. Select Unknown next to Token Id and select Constant. Click the dropdown list and select the appropriate token.
  6. Click the Done path and navigate to All Steps [Catalog] > Data > JSON. Select the Json Deserialize step and click ADD.
  7. Under PARAMETERS, click the dropdown under JSON Type and select an appropriate JSON Type.
  8. 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.
  9. Connect the Done and Error path to the End step. Click Save to save changes.


Debug

  1. On the top action bar, click Debug. Then, click START DEBUGGING.
  2. Select the Json Deserialize step, select Execution 1, and click View Input/Output Data.



Was this article helpful?