# Salesforce

The **Salesforce** connector allows you to perform operations on the Salesforce platform.

## **Parameters**

Take a look at the configuration parameters of the connector. Parameters supported by [Double Braces expressions](https://docs.digibee.com/documentation/connectors-and-triggers/double-braces/overview) are marked with (DB).

### **General tab**

<table data-full-width="true"><thead><tr><th>Parameter</th><th>Description</th><th>Default value</th><th>Data type</th></tr></thead><tbody><tr><td><strong>Fail On Error</strong></td><td>If enabled, interrupts the pipeline execution when an error occurs. If disabled, execution continues, but the <code>"success"</code> property will be set to <code>false</code>.</td><td>False</td><td>Boolean</td></tr></tbody></table>

### **Authentication tab**

<table data-full-width="true"><thead><tr><th>Parameter</th><th>Description</th><th>Default value</th><th>Data type</th></tr></thead><tbody><tr><td><strong>Salesforce Login URL</strong> <code>(DB)</code></td><td>URL used for Salesforce authentication.</td><td>N/A</td><td>String</td></tr><tr><td><strong>Salesforce Client Account</strong></td><td>Connected App account with the Client ID. Supported types: <strong>OAuth Provider</strong>.</td><td>N/A</td><td>Account</td></tr><tr><td><strong>OAuth Authentication Flow</strong></td><td>Authentication type used in the Salesforce app: <strong>JWT Bearer Token Flow</strong> or <strong>Username-Password Flow</strong>.</td><td>N/A</td><td>String</td></tr><tr><td><strong>Operation Account</strong></td><td>Account used to perform Salesforce operations. Supported accounts: <strong>Basic</strong>, <strong>Certificate-Chain.</strong></td><td>N/A</td><td>Account</td></tr><tr><td><strong>Subject</strong></td><td>User used for authentication with the Salesforce app. Available only with <strong>JWT Bearer Token Flow</strong>.</td><td>N/A</td><td>String</td></tr></tbody></table>

### **Salesforce API tab**

The **Salesforce** connector can automatically retrieve all available entities on the Salesforce platform to simplify configuration.

{% hint style="warning" %}
**Important information:**

* To use this feature, you must configure a valid Salesforce account and URL. If no account is selected in **Operation Account**, or the credentials are invalid, the connector switches automatically to **RAW** mode, which requires manual configuration.
* In [**Capsules**](https://app.gitbook.com/s/jvO5S91EQURCEhbZOuuZ/development-cycle/build-overview/capsulas), only **RAW** mode is supported. This means all configurations, including the **API Version** parameter, must be set up manually. The use of [Double Braces](https://docs.digibee.com/documentation/connectors-and-triggers/double-braces/overview) syntax is supported.
  {% endhint %}

#### **AuthToken Reuse**

When accessing the **Salesforce API** tab, the connector generates an access token with limited validity that may expire.

To prevent frequent token regeneration, Digibee offers **AuthToken Reuse** for the username-password flow. This allows configuring a new connection in the Salesforce portal and reusing the existing token.

See [how to configure this mechanism](https://docs.digibee.com/documentation/connectors-and-triggers/connectors/enterprise-applications/salesforce/authtoken-reuse-salesforce).

#### **Salesforce API tab parameters**

<table data-full-width="true"><thead><tr><th>Parameter</th><th>Description</th><th>Default value</th><th>Data type</th></tr></thead><tbody><tr><td><strong>API Version</strong></td><td>Salesforce API version.</td><td>{latest version}</td><td>String</td></tr><tr><td><strong>API Protocol</strong></td><td>Salesforce API to use: <strong>Bulk</strong>, <strong>Bulk 2.0</strong>, <strong>RAW</strong>, and <strong>Rest</strong>.</td><td>N/A</td><td>String</td></tr><tr><td><strong>Operation</strong></td><td>Operation to be performed on Salesforce API. See below in a dedicated section the available options for each API.</td><td>N/A</td><td>String</td></tr></tbody></table>

#### **RAW mode parameters**

When **API Protocol** is set to **RAW**, configure the following parameters manually:

<table data-full-width="true"><thead><tr><th>Parameter</th><th>Description</th><th>Default value</th><th>Data type</th></tr></thead><tbody><tr><td><strong>Method</strong></td><td>HTTP method to use.</td><td><code>GET</code></td><td>String</td></tr><tr><td><strong>Path</strong> <code>(DB)</code></td><td>Salesforce API endpoint path. Make sure to include the API version in the path.</td><td><code>/services/data/v51/sobjects/Account/</code></td><td>String</td></tr><tr><td><strong>Headers</strong> <code>(DB)</code></td><td>Required request headers.</td><td><code>Content-Type: application/json</code></td><td>String</td></tr><tr><td><strong>Object Fields</strong></td><td>List of keys that must match the ones defined in the <strong>Headers</strong> field. These keys are required here to ensure proper processing of the request. If a header is not listed in this field, it will not be included in the request.</td><td><code>Content-Type</code></td><td>String</td></tr><tr><td><strong>Body</strong> <code>(DB)</code></td><td>Request body.</td><td>N/A</td><td>JSON</td></tr></tbody></table>

#### **Available operations by API type**

**Bulk:**

* Abort Job
* Close Job
* Create Batch
* Create Batch Query
* Create Job
* Get All Batches
* Get Batch
* Get Job
* Get Query Result
* Get Query Result Ids
* Get Request
* Get Results

**Bulk 2.0:**

* Abort Job
* Abort Query Job
* Close Job
* Create Batch
* Create Job
* Create Query Job
* Delete Job
* Delete Query Job
* Get All Jobs
* Get All Query Jobs
* Get Failed Results
* Get Job
* Get Query Job
* Get Query Job Results
* Get Successful Results
* Get Unprocessed Records

**Rest:**

* Apex Call
* Approval
* Approvals
* Composite
* Composite-batch
* Composite Create SObject Collections
* Composite Delete SObject Collections
* Composite Retrieve SObject Collections
* Composite-tree
* Composite Update SObject Collections
* Composite Upsert SObject Collections
* Create SObject
* Delete SObject
* Delete SObject With Id
* Get Basic Info
* Get Blob Field
* Get Description
* Get Global Objects
* Get Resources
* Get SObject
* Get SObject With Id
* Get Versions
* Limits
* Query
* Query All
* Query More
* Recent
* Search
* Update SObject
* Upsert SObject

### **Advanced settings tab**

<table data-full-width="true"><thead><tr><th>Parameter</th><th>Description</th><th>Default value</th><th>Data type</th></tr></thead><tbody><tr><td><strong>Fields to NULL</strong></td><td>Defines if SObject fields with null values must be considered by the Salesforce API. By default, Salesforce ignores SObjects with null fields.</td><td>False</td><td>Boolean</td></tr></tbody></table>

### **Documentation tab**

<table data-full-width="true"><thead><tr><th>Parameter</th><th>Description</th><th>Default value</th><th>Data type</th></tr></thead><tbody><tr><td><strong>Documentation</strong></td><td>Optional field to describe the connector configuration and any relevant business rules.</td><td>N/A</td><td>String</td></tr></tbody></table>

## **Additional notes**

### **REST protocol**

#### **Composite operation**

When using the **Composite** operation, you must remove the base path from the `url` property to ensure the connector works correctly. For example:

```json
{
  "method": "POST",
  "url": "/services/data/v59.0/sobjects/Account",
  "referenceId": "refAccount",
  "body": {
    "Name": "Sample Account"
  }
}
```

In this case, remove the `/services/data/v59.0` part from the `url` property.

After editing, the correct `url` should be:

```json
{
  "method": "POST",
  "url": "/sobjects/Account",
  "referenceId": "refAccount",
  "body": {
    "Name": "Sample Account"
  }
}
```

#### **Composite Update SObject Collections operation**

The expected output for this operation is:

```json
{
  "success": true,
  "data": [
    {
      "id": "003ak00000XgSkrAAF",
      "errors": [],
      "success": true
    },
    {
      "id": "003ak00000XgSksAAF",
      "errors": [],
      "success": true
    },
    {
      "id": "003ak00000XgSktAAF",
      "errors": [],
      "success": true
    }
  ]
}
```

#### **Get Blob Field operation**

For this operation, the file can be received in two ways:

* As a base64 string
* As a file stored in the local pipeline directory

By default, the file is received in base64 format. To store it as a local file in the pipeline directory, enable the **Save as Local File** flag and specify the file name in the **File Name** field. You can then use file reader connectors later in the flow to process the saved file.

#### **Query operation**

For any **Query** operation (such as **Query**, **Query All**, or **Query More**), use this pattern:

```json
{
  "q": "SELECT Id, LastName, Company FROM Lead ORDER BY CreatedDate DESC LIMIT 5"
}
```

If you want to use [Double Braces expressions](https://docs.digibee.com/documentation/connectors-and-triggers/double-braces), write it like this:

```json
{
  "q": "{{ message.query }}"
}

```

### **Bulk 2.0 protocol**

#### **Create Batch operation**

The expected output for this operation is:

```json
{
  "success": true,
  "data": {
    "HttpResponseCode": "201",
    "HttpResponseText": "Created",
    "Content-type": "text/csv",
    "Sforce-Limit-Info": "api-usage=4184/15000"
  }
}
```
