Contact Us 1-800-596-4880

Using Anypoint Studio to Configure Salesforce Connector 10.20 - Mule 4

Anypoint Studio (Studio) editors help you design and update your Mule applications, properties, and configuration files.

To add and configure a connector in Studio:

When you run the connector, you can view the app log to check for problems, as described in View the App Log.

If you are new to configuring connectors in Studio, see Using Anypoint Studio to Configure a Connector. If, after reading this topic, you need additional information about the connector fields, see the Salesforce Reference.

Create a Mule Project

In Studio, create a new Mule project in which to add and configure the connector:

  1. In Studio, select File > New > Mule Project.

  2. Enter a name for your Mule project and click Finish.

Add the Connector to Your Mule Project

Add Salesforce Connector to your Mule project to automatically populate the XML code with the connector’s namespace and schema location and add the required dependencies to the project’s pom.xml file:

  1. In the Mule Palette view, click (X) Search in Exchange.

  2. In Add Modules to Project, type salesforce in the search field.

  3. Click the connector name in Available modules.

  4. Click Add.

  5. Click Finish.

Adding a connector to a Mule project in Studio does not make that connector available to other projects in your Studio workspace.

Configure a Source

A source initiates a flow when a specified condition is met. A channel or topic must be published to Salesforce before a subscription to the channel can be created.

You can configure one of these sources to use with Salesforce Connector:

  • On Deleted Object

    Initiates your app when a Salesforce user deletes an object. Possible object types are Contact, Lead, Account, Contracts, Opportunity, or the name of a custom object.

  • On Modified Object

    Initiates your app when a Salesforce user modifies an object. Possible object types are Contact, Lead, Account, Contracts, Opportunity, or the name of a custom object.

  • On New Object

    Initiates your app when a Salesforce user creates a new object. Possible object types are Contact, Lead, Account, Contracts, Opportunity, or the name of a custom object.

  • Replay channel listener

    Subscribes to a streaming channel. This source provides channel-related notification settings for new events and events stored by Salesforce within the 24-hour retention period. Events that occur in the specified channel source trigger the flow.

  • Replay topic listener

    Subscribes to a topic. This source provides topic-related notification settings for new events and events stored by Salesforce within the 24-hour retention period. Events that occur on records in the specified topic trigger the flow.

  • Subscribe channel listener

    Subscribes to a streaming channel. This source provides channel-related notification settings for new events that occur after you subscribe.

  • Subscribe topic listener

    Subscribe to a topic. This source provides topic-related notification settings for new events that occur after you subscribe.

  • HTTP > Listener.

    Initiates a flow each time it receives a request on the configured host and port

  • Scheduler

    Initiates a flow when a time-based condition is met.

A channel or topic must be published to Salesforce before a subscription to the channel can be created.

Example of Configuring a Source

For example, to configure On New Object as a source:

  1. In the Mule Palette view, select On New Object.

  2. Drag On New Object to the Studio canvas.

  3. In the On New Object properties window, specify a value for the Path field.

  4. Optionally change the value of the Display Name field.

  5. Select an object type and optionally specify a UTC value in the Since field.

    If the server is in a different time zone, you must specify a value in the Since field. If you leave the field empty, the connector uses the local timestamp.

  6. Click the plus sign (+) next to the Connector configuration field to configure a global element that can be used by all instances of the On New Object source in the app.

  7. In the TLS tab, optionally specify the TLS information for the connector.

  8. In the Advanced tab, optionally specify reconnection information, including a reconnection strategy.

  9. Click Test Connection to confirm that Mule can connect with the specified server.

  10. Click OK.

Redelivery Policy

To configure a redelivery policy for a source, set the Redelivery field in the source’s properties window to the maximum number of redelivery attempts allowed after an initial failure.

You can specify an object store for this policy. If you don’t specify an object store, Mule creates a nonpersistent object store. The number of transactions used to interact with the object store varies based on the number of retries configured for the redelivery policy.

For more information about configuring a redelivery policy, see Redelivery Policy.

Add a Connector Operation to the Flow

When you add a connector operation to your flow, you immediately define a specific operation for that connector to perform.

To add an operation for Salesforce Connector, follow these steps:

  1. In the Mule Palette view, select Salesforce and then select the desired operation.

  2. Drag the operation onto the Studio canvas to the right of the source.

Configure a Global Element for the Connector

When you configure a connector, configure a global element that all instances of that connector in the app can use. Configuring a global element requires you to provide the authentication credentials the connector uses to access the target Salesforce system.

You can reference a configuration file that contains ANT-style property placeholders (recommended), or you can enter your authorization credentials in the global configuration properties. For information about the benefits of using property placeholders and how to configure them, see Anypoint Connector Configuration.

To configure a global element for Salesforce Connector, follow these steps:

  1. Select the name of the connector in the Studio canvas.

  2. In the configuration screen for the operation, click the plus sign (+) next to the Connector configuration field to access the global element configuration fields.

  3. In the General tab, select one of these authentication methods for your connection:

  4. In the Apex tab, optionally configure Apex Settings.

  5. In the Advanced tab, optionally specify reconnection information, including a reconnection strategy.

  6. Click Test Connection to confirm that Mule can connect with the specified server.

  7. Click OK.

Authentication

For all OAuth connections, you can specify an object store that stores each resource owner’s ID data. If you don’t specify an object store, Mule automatically provisions the default object store. The app interacts with the object store automatically when a new resource owner is authenticated, the access token is refreshed, or the access token is invalidated.

All authentication types support mutual TLS. To use mutual TLS, you need a keystore file and a password for the file. See Generate a Keystore File for more information.

In Studio, when you configure the connector’s authentication method, specify the path to the keystore file and the TLS password on the Security tab.

To set up a mutual TLS certificate in your Salesforce environment, see Set Up a Mutual Authentication Certificate.

Basic Authentication

Basic authentication uses a username and password for authentication.

Important fields in the General tab include the following:

Field Description

Username

Salesforce username.

Password

Corresponding password.

Security token

Corresponding security token.

Callback path

Path for the callback, for example, /callback.

Authorization URL

Web service URL responsible for user authentication. This is the URL for the endpoint configured to handle SOAP authentication requests. It defaults to the URL that contains the latest API version supported by the connector, for example, https://login.salesforce.com/services/Soap/u/60.0.

OAuth 2.0 Authentication

Use OAuth 2.0 to delegate user authentication to the service hosting the user account. For more information, refer to Configuring OAuth 2.0 for Connectors or Configuring OAuth 2.0 for Connectors on CloudHub.

OAuth 2.0 delegates user authentication to the service hosting the user account.

Important fields in the General tab include the following:

Field Description

Consumer key

Consumer key for the Salesforce-connected app. See the Salesforce documentation for information about generating a consumer key.

Consumer secret

Password for the keystore.

Listener config

Configuration for the listener, for example, `HTTP_Listener_config.

Callback path

Path for the callback, for example, /callback.

Authorize path

Path for authorization, for example, /authorize.

External call back url

Callback URL, for example, http://localhost:8085/callback.

Important fields in the Advanced tab include the following:

Field Description

Api version

API version used. Defaults to the latest API version supported by the connector.

OAuth JWT Authentication

OAuth JWT uses OAuth 2.0 with a JSON Web Token (JWT) request for user authentication.

Important fields in the General tab include the following:

Field Description

Consumer key

Consumer key for the Salesforce-connected app. See the Salesforce documentation for information about generating a consumer key.

Key store

Path to the keystore that signs data during authentication. See Generate a Keystore File.

Store password

Password for the keystore.

Password

Corresponding password.

Certificate Alias

Alias of the certificate to use if the specified keystore contains multiple certificates.

Principal

Username of the Salesforce user.

Important fields in the Advanced tab include the following:

Field Description

Api version

API version used. Defaults to the latest API version supported by the connector.

OAuth SAML Authentication

OAuth SAML currently uses only Salesforce as an identity provider. Refer to Salesforce as a SAML Identity Provider to enable Salesforce as an identity provider.

OAuth SAML uses OAuth 2.0 with a signed SAML 2.0 assertion to request an access token.

Important fields in the General tab include the following:

Field Description

Consumer key

Consumer key for the Salesforce-connected app. See the Salesforce documentation for information about generating a consumer key.

Key store

Path to the keystore that signs data during authentication. See Generate a Keystore File.

Store password

Password for the keystore.

Password

Corresponding password.

Certificate Alias

Alias of the certificate to use if the specified keystore contains multiple certificates.

Principal

Username of the Salesforce user.

Important fields in the Advanced tab include the following:

Field Description

Api version

API version used. Defaults to the latest API version supported by the connector.

OAuth Username Password Authentication

OAuth Username Password authentication uses OAuth 2.0 with a user and password for authentication.

Important fields in the General tab include the following:

Field Description

Consumer key

Consumer key for the Salesforce-connected app. See the Salesforce documentation for information about generating a consumer key.

Consumer secret

Consumer secret for the connector to access Salesforce.

Username

Salesforce username.

Password

Corresponding password.

Security token

Corresponding security token.

Important fields in the Advanced tab include the following:

Field Description

Api version

API version used. Defaults to the latest API version supported by the connector.

Apex Settings

Salesforce Connector gets the names of the Apex classes and the associated methods that can be invoked when you connect to Salesforce.

To configure Apex settings in Studio:

  1. Click the Apex tab in the global element properties screen.

  2. Enter the following information:

    Field Description

    Fetch All Apex SOAP Metadata

    Fetches the metadata of all the Apex SOAP classes. Takes precedence over Apex Class Name settings.

    Fetch All Apex REST Metadata

    Fetches the metadata of all the Apex REST classes. Takes precedence over Apex Class Name settings.

    Apex Class Names

    List of Apex class names to use for limiting the set of classes you fetch and the methods that they expose. This setting can accelerate the fetch process if you don’t need to fetch many classes. Valid values:

    • None

      No classes are specified for DataSense to acquire.

    • From a message

      Enables you to specify the class name using an expression.

    • Create object manually

      Enables you to create a list of class names for DataSense to acquire. DataSense acquires only those classes and their associated methods.

Configure Additional Connector Fields

After you configure a global element for Salesforce Connector, configure the other required fields for the connector.

The following example shows four operations of the many you can configure for Salesforce Connector, as well as the important fields for these operations:

Operation Description

Create

Adds one or more new records to your organization’s data. Important fields include:

  • Type

    Salesforce object type

  • Records

    Function editor expression

Query

Executes a query against the specified object and returns data that matches the specified criteria. Important fields include:

  • Salesforce query

    Salesforce query to retrieve objects

  • Parameters

    Values for placeholders in the Salesforce query

Update

Updates one or more existing records in your organization’s data. Important fields include:

  • Type

    Salesforce object type

  • Records

    Function editor expression that produces a collection of Salesforce objects to update

Delete

Deletes one or more records from your organization’s data. Important fields include:

  • Records To Delete IDs

    Function editor expression that produces a collection of Salesforce objects to delete

View the App Log

To check for problems, you can view the app log as follows:

  • If you’re running the app from Anypoint Platform, the output is visible in the Anypoint Studio console window.

  • If you’re running the app using Mule from the command line, the app log is visible in your OS console.

Unless the log file path is customized in the app’s log file (log4j2.xml), you can also view the app log in the default location MULE_HOME/logs/<app-name>.log.

Next Step

After completing Studio setup, see Additional Configuration Information.

View on GitHub