Update External Data with MuleSoft Composer for Salesforce and RPA

Overview – Using MuleSoft Composer for Salesforce and External Systems

Integrating data with MuleSoft Composer for Salesforce and MuleSoft RPA easy. This article and corresponding video will show the straightforward process that enables updating Salesforce with external data from a MuleSoft RPA process.

As prerequisites, the following are required:

  • Salesforce, MuleSoft Composer, and MuleSoft RPA licenses
  • Anypoint Platform Credentials
  • MuleSoft Composer Credentials
  • Salesforce Org Credentials
  • Client ID and Client Secret for Connected App with “RPA Invocable Process” scope
  • Mulesoft RPA Tenant Name
  • Invokable MuleSoft RPA process in Production Phase

To see how to generate the invokable MuleSoft RPA process, the MuleSoft RPA tenant name, and the Connected App details, see our prior posts: Invoke MuleSoft RPA Process via HTTP and Postman Part 1 and Invoke MuleSoft RPA Process via HTTP and Postman Part 2.

The use case walked through here will show how to trigger a flow upon creation of a new Salesforce record, call a MuleSoft RPA process, and then update that Salesforce record with output data from the MuleSoft RPA process execution.

Step-by-Step Process in Composer

To start, log in to MuleSoft Composer, and from the main flow, go to Create new flow -> From scratch :

MuleSoft Composer Create and New Flow

The process asks what should start the flow; choose a System Event of type Salesforce. This configures the flow to be triggered by Salesforce activity:

Create a new system event in MuleSoft Composer

Add a new Salesforce connection; give a useful Connection Display Name and click Connect. This will pop up a Salesforce login window which requires entering valid Salesforce credentials:

Screen showing the Salesforce main login screen

Upon entering of valid credentials, an “Allow Access?” screen is shown. Allow access. At this point you have a successful Salesforce connection and are ready to configure the details of the trigger.

Fill in the form to provide the trigger data. The example here triggers upon any new Product record being created. It polls every 15 seconds for newly-created Products:

Finish Trigger config in MuleSoft Composer

After configuring this, the Trigger configuration is complete. Hit the plus button to create a new action step.

For this use case, the next step should also be a System Action. This System Action is of type MuleSoft RPA:

Select RPA System Action

Add a new Mulesoft RPA connection. Provide a meaningful Connection Display Name, and use Authorization Type = OAuth 2.0 Client Credentials. Then use the prerequisites mentioned above to fill in the RPA API URL, the Client ID (using the Connected App client ID), the Client Secret (the Connected App client secret), and the Token URL (this should be a standard value: https://anypoint.mulesoft.com/accounts/api/v2/oauth2/token). After configuring this, click Connect:

Connect to RPA Account

Once the connection is successfully established to MuleSoft RPA, select the relevant RPA process to be called as part of this Composer flow. And for Output, select “Use response in this flow”. The use case illustrated here also adds an input field to the RPA process; it sets the “BuildCategory” activity parameter for the RPA execution equal to the name of the Product that was created to trigger the flow:

Configure the action to Trigger the Flow

The flow is now configured to call the MuleSoft RPA process. The use case requires one more step; this step is another Action Step to update Salesforce with the RPA process’s output data.

Hit the plus button to add one more Action Step, and once again select System Action. Select Salesforce as the action type. Use the Salesforce connection that was created earlier in the process. This time, the action is “Update record”. Object Type is the same object type that was used to trigger the flow (Product). An ID (Product ID) is required to tell Composer which object to update. Set the value for Product ID = Product ID from the “On New record” trigger in the input box:

Add the ProductID field to the Flow

Add one more field from “Select Additional Fields” to add Product Description; this is the field that will get updated with the RPA output data in this use case. This particular use case uses a Custom Expression to enable multiple RPA output fields to be utilized in the Salesforce object update. Configure the expression as shown in the screenshot and hit Apply:

Custom Expression Editor

Custom Expression text

After applying the custom expression, the Update action is successfully configured:

Fully Configured Update action

Click Save and name the Composer flow appropriately. Once saved, click the Test button to test out the Composer flow. This will have Composer start polling for newly-created Product records in the configured Salesforce org:

Image of MuleSoft Composer test beginning

Image of MuleSoft Composer test running

Test it from Salesforce

With the Composer flow running its Test, open up Salesforce. Go to the Products tab. Click New:

Create New Product in Salesforce

Create a new Product with a useful Product Name (“Table” in this use case). As mentioned in the Composer setup section, the Product Name is mapped to the RPA BuildCategory input activity parameter. Leave the Product Description blank, as the Composer flow will be updating that field with RPA output. Click Save to create the Product:

Add data to new Product.

After clicking Save, go back to Composer where the Test is running. Within 15 seconds (the polling time), the Composer Test should move to a status of “Processing…”:

Image of Test in "Processing" status

It may take a minute or two for the RPA process to execute. Once it does, some output will show in each Action Step. The screenshot below shows the output data from the RPA process:

RPA Process data output

Next, verify that the Salesforce update completed correctly by going to the newly-created product in Salesforce and checking its Product Description. In this case, it shows that the Product is updated successfully:

Product Description field updated.

Conclusion – Using MuleSoft Composer for Salesforce and External Systems

This example is just one of thousands of use cases you could dream up.  The goal is to get you thinking about integrating your different systems, reducing duplication of effort, and feeling confident that with MuleSoft and RPA, anything can be connected to your Salesforce org (or any other systems you might have in play).

While MuleSoft Composer for Salesforce is our preferred way, your situation might be more complex and you could require MuleSoft Anypoint.  In either case, your data is within reach of multiple systems, safely, efficiently, and well-architected.

Check out the video presentation of this article:

Talk to the Professionals!

To learn more about our MuleSoft IDP, MuleSoft RPA, Partner Manager and EDI, or Salesforce services, please visit our website or fill out a Contact Us form here.

CloudFirst Labs logo