# Salesforce SOQL

UI Bakery allows you to easily connect to Salesforce SOQL with no need for additional layers like APIs or third-party services. \
You can connect Salesforce SOQL as a [standalone data source](#connecting-salesforce-as-a-standalone-data-source) or via an [HTTP data source](#connecting-salesforce-as-an-http-data-source).

## Configuration

### Connecting Salesforce SOQL as a standalone data source

1. On the **Data sources** page, click **Connect**, and select *Salesforce SOQL* in the Data sources list.
2. Give your data source a name and specify the **Salesforce URL** (optional).
3. Click **Connect to Salesforce** and authorize the access in the Salesforce app.
4. Finally, click **Test connection** to check whether the connection can be established, and then click **Connect Datasource** to complete the setup.

<figure><img src="https://837703843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUX6zPRMFFK0yrTghj7cY%2Fuploads%2Fio0bpCmXh0XIVIQ81R4U%2FCleanShot%202025-04-25%20at%2012.08.04%402x-min.png?alt=media&#x26;token=bf501116-e669-4157-a136-91ebd6395817" alt=""><figcaption></figcaption></figure>

### Connecting Salesforce SOQL as an HTTP data source

#### Prerequisites

First, you need to create a **connected app** in Salesforce SOQL. To do so, follow the instructions below:

1. In *Lightning Experience*, open **Setup**, navigate to **Apps** > **App Manager,** and click **New Connected App**.

<figure><img src="https://837703843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUX6zPRMFFK0yrTghj7cY%2Fuploads%2FLpd17zRbDyAoVzPLOgqH%2FCleanShot%202025-04-25%20at%2014.18.14%402x-min.png?alt=media&#x26;token=e1303353-c890-4b9c-b66f-bd37ca286cb8" alt=""><figcaption></figcaption></figure>

In *Salesforce Classic*, open **Setup**, navigate to **Build** > **Create** > **Apps**, scroll down to *Connected Apps*, and click **New**.

<figure><img src="https://837703843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUX6zPRMFFK0yrTghj7cY%2Fuploads%2Fi7Dqx1i9LsyCMIlZ5nWY%2FCleanShot%202025-04-25%20at%2014.12.34%402x-min.png?alt=media&#x26;token=b7edfaab-74a4-4785-8499-77059ec91cd4" alt=""><figcaption></figcaption></figure>

2. Specify all the required information in the *Basic Information* section.
3. Next, select the **Enable OAuth Settings** checkbox in the *API* section:
   1. Specify the following **Callback URL** - `https://cloud.uibakery.io/datasource-auth/callback`.
   2. In *Selected OAuth Scopes*, add all the OAuth scopes you need. Make sure to add the `Perform requests at any time` scope.&#x20;

{% hint style="warning" %}
Even though the `Full access` scope is a valid option that you can add, it's important to note that it doesn't grant all the necessary permissions.
{% endhint %}

<figure><img src="https://837703843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUX6zPRMFFK0yrTghj7cY%2Fuploads%2FA213D396ntC8tb3PNQXE%2FCleanShot%202025-04-25%20at%2014.30.25%402x-min.png?alt=media&#x26;token=0dd9dad3-de81-4801-a3ba-b86879c3a50e" alt=""><figcaption></figcaption></figure>

4. Click **Save**.

You'll be redirected to the *Manage Connected Apps* page. There, you can click **Manage Consumer Details** in the *API* section to copy the `Consumer Key` and `Consumer Secret` that will be required later.

#### Connecting the data source

Now, in UI Bakery, follow these steps to configure the Salesforce data source:

1. On the **Data sources** page, click **Connect**, and select *HTTP API* in the Data sources list.
2. In the **Authentication settings** dropdown, select OAuth2.
3. Next, in the **OAuth2 Flow** dropdown, select the flow you need:
   1. *Authorization Code Flow*
   2. *Client Credentials Flow*
   3. *Password Grant*

<details>

<summary><strong>Authorization Code Flow</strong></summary>

1. First, in your Connected App, deselect the **Require Proof Key for Code Exchange (PKCE) Extension for Supported Authorization Flows** checkbox in the *API* section and wait for up to 10 min for the changes to take effect.

<figure><img src="https://837703843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUX6zPRMFFK0yrTghj7cY%2Fuploads%2FWo7mxmLaWrGCeRfapxWY%2FCleanShot%202025-05-08%20at%2016.21.58%402x-min.png?alt=media&#x26;token=5fbae1db-84d6-4278-be6d-1ac5d4fca7d6" alt=""><figcaption></figcaption></figure>

2. Next, go back to the data source connection window and specify the **Client ID** (=Consumer Key) and **Client secret** (=Consumer Secret) from your connected app.
3. As the **Authorization URL**, specify `https://login.salesforce.com/services/oauth2/authorize`.
4. As the **Access Token URL**, specify `https://login.salesforce.com/services/oauth2/token`.

<figure><img src="https://837703843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUX6zPRMFFK0yrTghj7cY%2Fuploads%2FKzls35dilw50lG19IJtk%2FCleanShot%202025-05-08%20at%2015.15.59%402x-min.png?alt=media&#x26;token=05c956bb-ad4d-495a-92fb-65a918dbf29e" alt=""><figcaption></figcaption></figure>

</details>

<details>

<summary><strong>Client Credentials Flow</strong></summary>

1. First, in your Connected App, select the **Enable Client Credentials Flow** checkbox in the *API* section and wait for up to 10 min for the changes to take effect.

<figure><img src="https://837703843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUX6zPRMFFK0yrTghj7cY%2Fuploads%2F6xfbxSERR45a34P1jXi4%2FCleanShot%202025-05-08%20at%2016.30.07%402x-min%20(1).png?alt=media&#x26;token=41fa0750-dcb0-48ba-a3a0-abe1f5553b73" alt=""><figcaption></figcaption></figure>

2. Next, also in the Connected app settings you should assign a *Client Credentials User.*

<figure><img src="https://837703843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUX6zPRMFFK0yrTghj7cY%2Fuploads%2FWPb3EDh5oE6p2Q5hS5RH%2FCleanShot%202025-05-08%20at%2017.11.28%402x-min.png?alt=media&#x26;token=b0a13000-24cf-46a3-b6d1-da9914399758" alt=""><figcaption></figcaption></figure>

3. Now, go back to the data source connection window and specify the **Client ID** (=Consumer Key) and **Client secret** (=Consumer Secret) from your connected app.
4. As the **Access Token URL**, specify the following:\
   \
   `https://your_salesforce_domain_url/services/oauth2/token`.

<figure><img src="https://837703843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUX6zPRMFFK0yrTghj7cY%2Fuploads%2FIimrpEqFy9LOpulCDBel%2FCleanShot%202025-05-08%20at%2017.05.43%402x-min%20(1).png?alt=media&#x26;token=bc2c702b-0f85-491a-8c42-bef8ace4e9b6" alt=""><figcaption></figcaption></figure>

</details>

4. Click **Connect to API** first and then **Connect Datasource** to complete the setup.

## Troubleshooting

* If you encounter an error message while testing the connection, double-check that the *Callback URL* and *OAuth scopes* are correctly configured in Salesforce.
* Make sure your Salesforce instance URL ends in `.salesforce.com`.
* Make sure that the correct permissions are granted to the connected app.

## On-premise connection

Due to the on-premise version [limitations](https://docs.uibakery.io/on-premise/ui-bakery-on-premise#limitations), connection to Salesforce SOQL there requires additional setup. Refer to this page for more details:point\_down:

{% content-ref url="../../on-premise/additional-configurations/salesforce-connection-setup" %}
[salesforce-connection-setup](https://docs.uibakery.io/on-premise/additional-configurations/salesforce-connection-setup)
{% endcontent-ref %}

***

## Usage

Once you've established the connection between UI Bakery and Salesforce SOQL, you can start interacting with its data.

If you've connected Salesforce SOQL as a [standalone data source](#connecting-salesforce-as-a-standalone-data-source), the [SQL Query](https://docs.uibakery.io/reference/working-with-actions/sql-query) action type is supported for this data source.

If you've connected Salesforce SOQL as an [HTTP data source](#connecting-salesforce-as-an-http-data-source), the [HTTP Request](https://docs.uibakery.io/reference/working-with-actions/http-request) action type is supported for this data source.
