Contact Free trial Login

Salesforce Studio Configuration - Mule 4

To configure a connector in Anypoint Studio follow this process:

  1. Install the Salesforce connector.

  2. Configure the Salesforce connector.

  3. Configure an input source.

Install Salesforce

  1. In Studio, click the Anypoint Exchange icon in the Studio task bar.

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

  3. Search for the Salesforce connector, click on the connector in Exchange, and click Add to project.

  4. Follow the prompts.

Configure Salesforce

  1. Drag and drop a connector operation to the Studio canvas.

    To use the Salesforce connector as a message processor, drag one of these operations to the Source area of a flow:

    • On Deleted Object - Initiate 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 - Initiate 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 - Initiate 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 - Subscribe to a streaming channel. This trigger provides channel-related notification settings for new events and events stored by Salesforce within the 24-hour retention period. Events that take place in the specified channel trigger the flow.

      A channel or topic must be published to Salesforce before a subscription to the channel can be created.
    • Replay topic - Subscribe to a topic. This trigger provides topic-related notification settings for new events and events stored by Salesforce within the 24-hour retention period. Events that take place on records in the specified topic trigger the flow.

    • Subscribe channel - Subscribe to a streaming channel. This trigger provides channel-related notification settings for new events that take place after you subscribe.

    • Subscribe topic - Subscribe to a topic. This trigger provides topic-related notification settings for new events that take place 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 for the Since field; if the Since field is left empty, the connector takes the local timestamp. As servers are in datacenters located generally elsewhere from one’s location, use of the Since field is recommended.
  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 - The port number the proxy server runs on.

    • Username - The username to log in to the server.

    • Password - The corresponding password.

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

Basic Username Password

Important fields:

  • Username (required): Enter the Salesforce username.

  • Password (required): Enter the corresponding password.

  • Security token: Enter the corresponding security token.

OAuth 2.0

Important fields:

  • Display (required): How to optimize the display:

    • 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): The consumer key for the Salesforce-connected app. See Create a Consumer Key.

  • Consumer secret (required): The 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): The consumer key for the Salesforce-connected app. See Create a Consumer Key.

  • Key store (required): See Generate a Keystore File.

  • Store password (required): The password for the keystore.

  • Principal (required): The password for the keystore.

OAuth SAML

Important fields:

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

  • Key store (required): See Generate a Keystore File.

  • Store password (required): The password for the keystore.

  • Principal (required) The password for the keystore.

OAuth Username Password

Important fields:

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

  • Consumer secret (required): The consumer secret for the connector to access Salesforce.

  • Username (required): Enter the Salesforce username.

  • Password (required): Enter the corresponding password.

  • Security token: Enter the corresponding security token.

Connector Property Values

The following are four example operations of the many you can set for the Salesforce connector. These are the important fields for these example 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 be updated.

Delete

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

Create a Consumer Key

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

This procedure provides guidance on using Salesforce to create a consumer key, and explains how to create a connected app in Salesforce. However, the steps might differ somewhat 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 into Salesforce, and go to Setup > Build > Create > Apps.

  2. Under the Connected App section, click New.

  3. To create a new connected app, enter:

    • A name for the connected app.

    • The API name.

    • Contact email.

  4. Under API (Enable OAuth Settings), select Enable OAuth Settings:

    • Enter the Callback URL.

    • Select the Use Digital Signatures checkbox.

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

      In Studio, you typically store this in the workspace that contains your Mule application.

  5. Add and Save these OAuth scopes to Selected OAuth Scopes:

    Full Access (full) and Perform Requests On Your Behalf At Any Time (refresh_token, offline_access)

  6. Configure the Authorization Settings for the app.

  7. Click Manage. In the OAuth Policies section, expand the Permitted Users dropdown, and select Admin Approved Users are Pre-Authorized. Then click Save.

  8. Under the Profiles section, click Manage Profiles.

  9. Select your user profile and click Save.

  10. Go back to the list of Connected Apps: Build > Create > Apps.

  11. Under the Connected Apps section, select the connected app you created.

You can see the Consumer Key that you need to provide in your connector’s configuration.

Generate a Keystore File

The Keystore 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:

    • Password for the keystore.

    • Your first name and last name.

    • Your organization unit.

    • Name of your city, state, and the two letters code of your country.

      The system generates a Java keystore file containing a private or public key pair in your workspace. The generated keystore file is in JKS format.

  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. Make sure 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 this you need a keystore file in the JKS format, and a password for it. See Generate a Keystore File for more information.

Simply specify the path to the keystore file and the password in the configuration window (as shown in the image below) and any user that requires Mutual TLS authentication is able to login using the connector.

Mutual TLS

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

Keep a Session Alive

For the Mule 4 Salesforce Connector, you have the option to keep the session alive until it expires by setting the Disable session invalidation field to True in the Global Element Properties > General > Advanced tab, or by setting disableSessionInvalidation="true" in the XML flow.

The Mule app controls the lifecycle connections. When the app determines that a given connection is not needed anymore, it checks the setting of Disable Session Invalidation. When the setting is False (the default), the connector automatically destroys the connection for the session. To prevent a session from closing in this case, you can set the Disable Session Invalidation field to True or provide a function expression.

Salesforce uses the same session for all your threads, so for example, if your session is active and you log in again, Salesforce uses the existing session instead of creating a new one.

If the Disable session invalidation field is set to False, the connector automatically destroys the session after it’s no longer needed.

You should keep the session alive when you are working with threads or concurrency in general. Salesforce uses the same session for all your threads (for example, if you have an active session and you log in again, Salesforce uses the existing session instead of creating a new one). To make sure the connection doesn’t close when a thread is finished, you should set the Disable session invalidation field to True in the Connection section of the connector’s global element properties.

Disable Session Field

Apex Settings

You can set Apex REST and SOAP access using Studio or in XML. When you connect to Salesforce, the Salesforce connector gets the names of the Apex classes and methods belonging to them 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 speed the fetch process if there are a lot of classes that you do not need to fetch.

You can provide Apex settings in Design Center and in Anypoint 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 - Lets you specify the class name using an expression.

  • Create object manually - You can create a list and add class names to the list - only those classes and their methods are acquired by DataSense.

The Fetch All Apex SOAP Metadata and Fetch All Apex REST Metadata check boxes 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.

We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices here. By continuing to use this site you are giving us your consent to do this.