Contact Free trial Login

Salesforce Studio Configuration - Mule 4

To configure a connector in Anypoint Studio follow this process:

  1. Add Anypoint Connector for Salesforce (Salesforce Connector) to your project.

  2. Configure the connector.

Add the Connector to Your Project

Studio provides two ways to add the connector to your Studio project: from the Exchange button in the Studio taskbar or from the Mule Palette view.

Add the Connector Using Exchange

  1. In Studio, create a Mule project.

  2. Click the Exchange icon (X) in the upper-left of the Studio task bar.

  3. In Exchange, click Login and supply your Anypoint Platform username and password.

  4. In Exchange, search for Salesforce.

  5. Select the connector and click Add to project.

  6. Follow the prompts to install the connector.

Add the Connector in Studio

  1. In Studio, create a Mule project.

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

  3. In Add Modules to Project, type Salesforce in the search field.

  4. Click this connector’s name in Available modules.

  5. Click Add.

  6. Click Finish.

Configure Salesforce

  1. Drag a connector operation to the Studio canvas.

    To use Salesforce Connector as an input source, drag one of these operations to the Source area of a flow. A channel or topic must be published to Salesforce before a subscription to the channel can be created.

    • 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 input 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 input source trigger the flow.

    • Replay topic listener

      Subscribes to a topic. This input 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 input source provides channel-related notification settings for new events that occur after you subscribe.

    • Subscribe topic listener

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

      For the On New Object and On Modified Object operations, specify a UTC value in the Since field. If the server is in a different time zone, you must specify a value in this field. If you leave the field empty, the connector uses the local timestamp.

  2. Click the operation.

  3. Click the green plus sign to the right of Connector Configuration.

  4. In the Connection field, choose one of the following connection types:

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

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

Basic Authentication

Important fields:

  • 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

Important fields:

  • Page

    Full-page authorization screen (default)

  • Popup

    Compact dialog optimized for web browser popup windows

  • Touch

    Mobile-optimized dialog for smart phones, such as Android and iPhone

  • 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

Important fields:

  • 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

  • Principal (required)

    Username of the Salesforce user

OAuth SAML

Important fields:

  • 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

  • Principal (required)

    Username of the Salesforce user

OAuth Username Password

Important fields:

  • 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

Connector Property Values

The following example shows four operations of the many you can set 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

  • 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 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

The Key Store field is the path to the keystore used to sign data during authentication. Only the Java keystore (JKS) format is allowed.

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 in the JKS format 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 all 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 Design Center and in Studio 7. See also Apex 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.

Next

After completing Studio set up, see Additional Configuration Information.