Contact Us 1-800-596-4880

Using Anypoint Studio to Configure Salesforce Connector 10.7 - 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 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 input 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.

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. Click the plus sign (+) next to the Connector configuration field to configure a global element that can be used by all instances of On New Object in the app.

  4. On the General tab, select a connection type and complete the required fields.

  5. On the Security tab, optionally specify the TLS information for the connector.

  6. On the Advanced tab, optionally specify a connection timeout, proxy configuration, session ID service endpoint, and reconnection information, including a reconnection strategy.

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

  8. Click OK.

  9. On the On New Object properties window, 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.

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, 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, it’s best to 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.

To configure the 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. On the General tab, configure the authentication connection type:

  4. For each of the connection choices, you can set optional proxy values:

    • Host

      Host name of the proxy server

    • Port

      Number of the port on which the proxy server runs

    • Username

      Username to log in to the server

    • Password

      Corresponding password

  5. On 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.

After completing the fields in the Global Element Properties screen, return to the main connector menu and set the Connector Property Values.

Basic Authentication

Basic authentication uses a username and password for authentication.

Important fields include the following:

  • Username (required)
    Salesforce username

  • Password (required)
    Corresponding password

  • Security token
    Corresponding security token

  • Authorization URL
    URL for the endpoint configured to process SOAP authentication requests

OAuth 2.0

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

Important fields include the following:

  • Consumer key (required):
    Consumer key for the Salesforce-connected app. See Create a Consumer Key.

  • Consumer secret (required)
    Consumer secret for the connector to access Salesforce

  • Listener config (required)
    Configuration for the listener, for example, HTTP_Listener_config

  • Callback path (required)
    Path for the callback, for example, /callback

  • Authorize path (required)
    Path for authorization, for example, /authorize

  • External callback url
    Callback URL, for example, http://localhost:8085/callback

OAuth JWT

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

Important fields include the following:

  • Consumer key (required)

    Consumer key for the Salesforce-connected app. See Create a Consumer Key.

  • Key store (required)

  • Store password (required)

    Password for the keystore

  • Certificate Alias (optional)

    The alias of the certificate to be used if the specified keystore contains multiple certificates

  • Principal (required)

    Username of the Salesforce user

OAuth SAML

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

Important fields include the following:

  • Consumer key (required)

    Consumer key for the Salesforce-connected app. See Create a Consumer Key.

  • Key store (required)

  • Store password (required)

    Password for the keystore

  • Certificate Alias (optional)

    The alias of the certificate to be used if the specified keystore contains multiple certificates

  • Principal (required)

    Username of the Salesforce user

OAuth Username Password

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

Important fields include the following:

  • Consumer key (required)

    Consumer key for the Salesforce-connected app. See Create a Consumer Key.

  • Consumer secret (required)

    Consumer secret for the connector to access Salesforce

  • Username (required)

    Salesforce username

  • Password (required)

    Corresponding password

  • Security token

    Corresponding security token

Configure Additional Connector Fields

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

Connector Property Values

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 Important Fields

Create

  • Type: Salesforce object type

  • Records: Function editor expression

Query

v10.1/salesforce-connector-101

  • Salesforce query: Salesforce query to retrieve objects.

  • Parameters: Values for placeholders in the Salesforce query

Update

  • Type: Salesforce object type.

  • Records: Function editor expression to produce a collection of Salesforce objects to update

Delete

  • Records To Delete IDs: Function editor expression to produce a collection of Salesforce objects to delete

Create a Consumer Key

A consumer key is required when setting up OAuth 2.0 configurations for Salesforce Connector. It is used by the OAuth, JWT, and SAML bearer configurations, and by the OAuth Username and Password configuration.

This procedure provides guidance for using Salesforce to create a consumer key and explains how to create a connected app in Salesforce. However, the steps might differ in your Salesforce instance.

This procedure assumes that you already have a certification file (such as salesforce-cert.crt). If not, you can produce one by generating a Java keystore and public key.

  1. Log in to Salesforce.

  2. From Setup, enter Apps in the Quick Find box.

  3. Click App Manager.

  4. Click New Connected App.

  5. To create a new connected app, enter:

    • A name for the connected app

    • The API name

    • The contact email

  6. In the API (Enable OAuth Settings) section, select the Enable OAuth Settings checkbox:

    • Enter the Callback URL.

    • Select the Use Digital Signatures checkbox.

    • Click Choose File and load your Salesforce certificate (for example, salesforce-cert.crt), which contains your public key.

      In Studio, you typically store the certificate in the workspace that contains your Mule app.

  7. Add and save these OAuth scopes to Selected OAuth Scopes:

    • Full Access (full)

    • Perform Requests On Your Behalf At Any Time (refresh_token, offline_access)

  8. Configure the authorization settings for the app.

  9. Click Manage.

  10. In the OAuth Policies section, expand the Permitted Users list and select Admin Approved Users are Pre-Authorized.

  11. Click Save.

  12. In the Profiles section, click Manage Profiles.

  13. Select your user profile and click Save.

  14. Select Build > Create > Apps to return to the list of connected apps.

  15. In the Connected Apps section, select the connected app you created.

You can now see the consumer key that you need to provide in your connector’s configuration.

Generate a Keystore File

This example demonstrates how to create a JKS keystore (PKCS12 format is also supported).

The Key Store field is the path to the keystore used to sign data during authentication.

To generate a keystore file:

  1. Go to your Mule workspace and open the command prompt (for Windows) or Terminal (for Mac).

  2. Type this command and press enter:

    keytool -genkeypair -alias salesforce-cert -keyalg RSA -keystore salesforce-cert.jks
  3. Enter the following information:

    • Password for the keystore

    • Your first name and last name

    • Your organization unit

    • Name of your city, state, and the two-letter code for your country

      The system generates a Java keystore file (JKS format) that contains a private or public key pair in your workspace.

  4. Provide the file path for the keystore in your connector configuration.

    Type this command and press enter:

    keytool -exportcert -alias salesforce-cert -file salesforce-cert.crt -keystore salesforce-cert.jks

    The system exports the public key from the keystore into the workspace. This is the public key that you need to enter in your Salesforce instance.

  5. Verify that you have both the keystore (salesforce-cert.jks) and the public key (salesforce-cert.crt) files in your workspace.

Use Mutual TLS

In v9.7.0 and later, 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.

Specify the path to the keystore file and the password in the configuration window:

Mutual TLS

Any user requiring mutual TLS authentication can log in using the connector.

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

Apex Settings

You can configure Apex REST and SOAP access using Studio or XML. When you connect to Salesforce, Salesforce Connector gets the names of the Apex classes and the associated methods that can be invoked.

All Salesforce connection configurations support these Apex settings:

  • 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, along with the methods they expose. This setting can accelerate the fetch process if there are many classes that you do not need to fetch.

You can provide Apex settings in Studio. See also XML Settings.

Click the Apex tab to choose the settings.

Apex settings values:

  • Fetch All Apex SOAP Metadata

    Fetches the metadata of all the Apex SOAP classes

  • Fetch All Apex REST Metadata

    Fetches the metadata of all the all Apex REST classes

Apex Class Names:

The Expression, Edit inline, or Bean reference choices provide these options:

  • None

    No Apex class name is mentioned 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.

The Fetch All Apex SOAP Metadata and Fetch All Apex REST Metadata checkboxes take precedence over the Apex Class Names setting. If these boxes are selected, they fetch all the Apex SOAP metadata or Apex REST metadata, regardless of your selection in the Apex Class Names section.

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

After completing Studio setup, see Additional Configuration Information.

View on GitHub