---
schema_version: "1"
id: 6af0166a8e5797996a36ec6178785e96f5285415247c9e32029cd3cbcfae1988
title: Salesforce Connector Reference
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/composer/ms_composer_salesforce_reference.md
canonical_url: https://docs.mulesoft.com/composer/ms_composer_salesforce_reference
source_site: docs.mulesoft.com
content_type: documentation
content_hash: e01d7106514b5843c167cb954c57090a7f40c7d249f39b56669ac58132a93010
description: MuleSoft Documentation Site
latest: true
---
---
product: Composer
---

# Salesforce Connector Reference

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

Use Salesforce as a data source (take new Salesforce records and copy them to a Google Sheet, for
example) or a data target (take a new employee in Workday and create a contact in Salesforce). Some
details of how to work with data in a flow are specific to the data source or data target. The
details also depend on the trigger or actions you choose.

## Connections

To connect to a system, whether it is a source of data or the target where you are sending data, you
must create a connection with that system’s required credentials. You typically connect to different
systems within a flow and can reuse each connection every time you need to connect.

This system requires the following credential information for its connections:

Connection Name

Enter a connection name that will help you remember the details of this connection. You can reuse
connections multiple times in a single flow, and in more than one flow, and the credentials are
hidden after you create the connection. Therefore, it’s helpful to provide a name that easily
identifies this connection from others.

Only you can see the connection. Other users in your Composer app must create their own connections.

Username and password

The username and password that you used to log in to Salesforce. You’ll need to create a connection
even if the data source is the same Salesforce org where you operate Composer. However, Composer
won’t ask for your password again. Instead, it displays an authentication approval dialog.

URL

The URL that you used to log in to Salesforce, for example, `myOrg.salesforce.com`.

### Salesforce Connected App Limits

Salesforce allows each user to grant access to no more than five connected apps at a time. Because
of this limit, if you create more than five Composer connections to the same Salesforce org,
Salesforce revokes tokens from the oldest to the most recently created, without notice, until the
number of authorized tokens returns to five.

If possible, create only one connection per user per Salesforce org to avoid this issue.

For more about Salesforce connected apps and authorization, see the
[Salesforce documentation](https://help.salesforce.com/s/articleView?id=xcloud.remoteaccess_request_manage.htm&type=5).

### Relaxed IP Restrictions

If your org has IP restrictions set, errors that reference IP or OAuth failures may occur. Relax the
IP restrictions to resolve this error.

To relax IP restrictions on a connection to Salesforce:

1.  Log into the Salesforce org. You must be a Salesforce admin in that org.

2.  Navigate to **Setup > Connected Apps OAuth Usage**.

3.  Find **MuleSoft Platform** in the list with the description **MuleSoft OCS app for KPROD**, and
    click **Install**.

4.  Click **Install** on the authorization dialog.

    This makes the connected app (the connection you created) available so that you can relax the IP
    restrictions. It doesn’t reinstall the Composer app.

5.  Click **Edit Policies**.

6.  Change IP Relaxation to **Relax IP Restrictions** and then save your change.

IP restrictions are now relaxed for the connection.

### Change a Connection

To change a connection:

1.  Open the flow.

2.  Click the change icon in the trigger or every action that connects to a sandbox:

    ![A button that says Change the Connection](/mulesoft/current/en-us/composer/_images/images/change-connection.png)

3.  Choose a new connection and save your changes.

### Resolve an Invalid Salesforce Connection

A Salesforce connection can become invalid when Salesforce certificates are renewed or generated, or
when an access token expires and Composer can’t refresh it. When the connection is invalid, flows
that use it fail to activate, with errors such as `AccessToken expired` or
`500 Internal Server Error`.

> [!NOTE] Before you change the connection, record the field mappings in each flow. For example,
> take screenshots so you can re-create them.

1.  Create a Salesforce connection. Use a dedicated service account or Salesforce admin account so
    the connection doesn’t depend on an individual user’s access.

2.  Open each flow that uses the old connection.

3.  In the trigger and every action that uses the old connection, select the change icon, and then
    select the new connection. See [Change a Connection](#change-a-connection).

4.  Add the field mappings again. Changing the connection removes the existing mappings from the
    trigger and actions, and Composer doesn’t restore them.

5.  Save the flow, and then activate it again.

### Salesforce Sandbox and Production Orgs

You can connect to Salesforce sandbox and production orgs.

To protect your production org:

1.  Connect to a sandbox org when you build and test a flow.

2.  After testing is complete, connect to a production org, test the flow with the new connection,
    and then activate the flow.

    Remember to change the connection from sandbox to production in every trigger and action that
    uses the sandbox connection.

### Null Values

By default, Composer ignores fields with empty (_null_) values. To change this behavior to clear the
existing value of the field when the field value is null, on the card, click the gear, and then
select `Clear on Null Values`.

## Transfer Binary Files

You can transfer binary files as field inputs using data pills from within your Composer flow. For
example, when keeping files in sync between Salesforce instances, you can download binary file
content from one instance and later upload that same file content to another instance.

The following Salesforce objects support binary transfers:

- `Content`

- `Version Document`

- `Attachment`

The recommended file size limit per transfer is 25MB and files transferred across systems cannot be
truncated.

## Triggers

Each flow starts with either a _scheduler_ or a _trigger_. Schedulers are set to a default frequency
of 15 minutes. Triggers, such as "each time a new record is created", are defined by you and provide
multiple options related to the data in your system.

Triggers use a polling process to actively check for new updates from an external system. The
polling frequency is 15 seconds.

This system provides the following trigger options:

New record

Checks for a new record every 15 seconds.

New or updated record

Checks for new or updated records of the specified object type every 15 seconds.

Deleted record

Checks for soft-deleted records. Soft-deleted records are stored in Salesforce for approximately 15
days.

Records are typically stored for approximately 15 days before being hard-deleted and irretrievable.
\* You can’t modify the soft-delete timestamp.

### Trigger Conditions

You can add trigger conditions to specify which conditions should trigger a workflow, for example,
you can restrict a workflow to trigger only when a specific field meets the conditions you specify.

To add a trigger condition:

1.  Select a trigger.

2.  In the **Trigger Conditions** section, click on the **Criteria** dropdown menu and select either
    **All Conditions Must Be Met (AND)** or **Any Condition Must Be Met (OR)**.

3.  Specify your conditions for specific fields.

To add more trigger conditions, click **Add Condition**.

### Polling Frequency

For triggers in this connector, the **Polling Frequency** field is required. This field enables you
to select how often Composer makes a request to the underling system API to look for changes to
records in active flows. You can select a different polling frequency for each flow in your
organization. With a shorter frequency, the flow executes more often; however, a shorter frequency
consumes more [API calls](https://docs.mulesoft.com/general/automation-credits-usage-and-rates). For example, if you have
an order management flow, you might require nearly real-time updates, which can be achieved with a
15-second polling interval (which equates to 5760 API calls per day). In contrast, if your flow
updates a pricing catalog, you could poll the flow every hour (which equates to 24 API calls per
day).

## Actions

After you connect to a system and define the trigger or configure a scheduler, you define the
actions that the flow performs. For example, you can copy a record between different systems, such
as Workday and Salesforce. The actions you can perform depend on which system you are connected to.

This system provides the following actions:

Create new record

Create a standard or custom record.

While creating a new record, any rules associated with the record are triggered based on the user’s
role.

Update record

Update any standard or custom record as specified by an external ID.

Get records

Return all the records that match specified criteria:

![Get Records example action configuration for Salesforce Connector](/mulesoft/current/en-us/composer/_images/images/get-records-salesforce.png)

- You can choose which fields the action fetches in the **Result fields** section.

- You can add one or more conditions to specify which types of records should be returned in the
  **Criteria** section. For example, you could specify that the last name begin with "B."

- You can control the sort order of the returned records in the **Sort records** section. Records
  can be sorted in ascending or descending order of a field that you specify.

- You can select **All records** in the **How Many Records to Retrieve** section to retrieve a list
  of records that match your criteria. The **All records** option is selected by default. If you
  want to access a single record from the list, you must add a
  [For Each loop](https://docs.mulesoft.com/composer/ms_composer_flows#create-and-test-a-for-each-loop) to your flow.

- If you have filtered your search with a unique identifier, you can select **Only the first
  record** in the **How Many Records to Retrieve** section to return a single record. Returning a
  single record will change the output of the search from a _list_ to a _single_ record. The **Get
  records** action searches for all records and returns only the first record in the list.  
  If you previously selected **All records** and then changed your selection to **Only the first
  record**, data pills in your existing flow could be invalidated.

When **Get Records** is a step in your flow, if Field-Level Encryption is enabled and you’re trying
to filter on an encrypted field, only the following string operators are supported: `equals`,
`not equals`, or empty. Field-Level Encryption doesn’t support `contains`, `starts with`, or
`ends with`. For more information on Field-Level Encryption, see the
[Salesforce documentation](https://help.salesforce.com/s/articleView?id=mktg.mc_overview_field_level_encryption_limitiations.htm&type=5).

Create or update record

Update any standard or custom record as specified by record ID. If the record ID isn’t found, create
the record.

Delete record

Delete a record specified by its object type and record ID.

Upload file

Adds a file to a folder in Salesforce.

Download file

Returns the binary contents of the specified file.

## Set Error from Action Preferences

If an error occurs within your flow, the error details appear on the **Run History** page. The **Run
History** page displays the date and time on which the error occurred, an explanation of the error,
and the location within the flow where the error occurred. Using this information, you can
troubleshoot issues within your flow. However, you can proactively set preferences in advance for
handling errors that may occur.

To set an error from action preference:

1.  Select an action.

2.  In the **If an error occurs section**, select one of the following:

    1.  **Stop Flow**

    2.  **Continue to next step**

    3.  **Create an error branch**

    4.  **Continue to another branch**

The error from action preference is set. If an error occurs, the selected preference is enacted in
the flow.

## Objects

All standard and custom Salesforce objects are available.

Some products in Marketing Cloud and Commerce Cloud use data that is not stored in Salesforce
records and therefore is not available with a Salesforce connection.

## See Also

- [Mulesoft Composer: Overview](https://docs.mulesoft.com/composer/ms_composer_overview)

- [MuleSoft Composer: Getting Started](https://docs.mulesoft.com/composer/ms_composer_prerequisites)

- [Composer Connector Reference](https://docs.mulesoft.com/composer/ms_composer_reference)

- [Knowledge Articles](https://help.salesforce.com/s/)
