How to Configure Salesforce Composite Connector using Mule 4?

on

|

views

and

comments

Hello Everyone,

In this blog post, we are going to learn how we can configure the Salesforce Composite Connector using Mule 4.

Anypoint Connector for Salesforce Composite (Salesforce Composite Connector) provides a way to integrate with the Salesforce Composite API. The connector exposes convenient methods for preparing subrequests, executing them in a batch, and parsing the results. The connector provides DataSense for the preparation of subrequests and for parsing a response of an execution.

According to MuleSoft.com

There is ample no of operations that we can perform using Salesforce Composite Connector. To see the list of all the Operations visit This link.

In this blog post we will see how we can configure composite connector and perform a Pre Query operation.

Step1 – Create a Mule Project

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

  1. Select File > New > Mule Project.
  2. Enter a name for your Mule project and click Finish.

Step2 -Add the Composite Connector to Your Mule Project

Add Salesforce Composite Connector to your Mule project, follow the below steps:

  1. In the Mule Palette view, click Search in Exchange.
  2. In Add Modules to Project,  type “Salesforce Composite” in the search box
  3. Click Salesforce Composite in Available modules.
  4. Click Add.
  5. Click Finish.
  6. Refer below Image

Step3 – Configure a Source

A source initiates a flow when a specified condition is met. You can configure one of these sources to use with Salesforce Composite Connector: For the demo, we are going to Use HTTP Listener

  1. HTTP Listener – Initiates a flow each time it receives a request on the configured host and port

For example, to configure an HTTP listener, follow these steps:

  1. In the Mule Palette view, select HTTP > Listener.
  2. Drag Listener to the Studio canvas.
  3. On the Listener configuration screen, optionally change the value of the Display Name field.
  4. Specify a value for the Path field.
  5. Click the plus sign (+) next to Connector configuration to configure a global element that can be used by all instances of HTTP Listener in the app.
  6. On the General tab, specify connection information for the connector.
  7. Click Test Connection to confirm that Mule can connect with the specified server.
  8. Click OK.
  9. Refer below images

Step4 – Add a Composite Connector Operation to the Flow

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

  1. In the Mule Palette view, select Salesforce Composite and then select the pre query operation.
  2. Drag the operation onto the Studio canvas to the right of the input source.
  3. Click the plus sign (+) next to Connector configuration to configure a global element that can be used by all instances of Salesforce Composite in the app.
  4. Select “OAuth JWT” for connection. To configure visit “How to Authenticate Salesforce using JWT from Mulesoft”
  5. On the General tab, specify connection information for the connector.
  6. Click Test Connection to confirm that Mule can connect with the specified server.
  7. Click OK.

Use below code for Composite Request pre query operation

{
  "compositeRequest": [
    {
      "method": "GET",
      "url": "/services/data/v51.0/query/?q=SELECT+Id,Name,Email,Phone,Fax+FROM+Contact+Limit+10",
      "referenceId": "refc"
    },
    {
      "method": "GET",
      "url": "/services/data/v51.0/query/?q=SELECT+Id,name+FROM+Account",
      "referenceId": "refa"
    },
    {
      "method": "GET",
      "url": "/services/data/v51.0/query/?q=SELECT+Id,name+FROM+organization",
      "referenceId": "refo"
    }
  ]
}

You can also use “Select Id, Name From Account”

Step5 – Configure Transform Message

  1. In the Mule Palette view, select Favorites > Transform Message ( core ).
  2. Drag Transform Message ( core ) to the Studio canvas.
  3. Use below code
%dw 2.0
output application/json
---
payload

Step6 – Run the Project

  1. Right-click on the canvas
  2. Select Run Project “Project Name”
  3. Hit the URL from the browser or Postman
  4. See the outcome

Thanks for reading 🙂 Please do like share & Subscribe

#Mule4 #Integration #MuleSoft #SalesforceCompositeConnector

Amit Singh
Amit Singhhttps://www.pantherschools.com/
Amit Singh aka @sfdcpanther/pantherschools, a Salesforce Technical Architect, Consultant with over 8+ years of experience in Salesforce technology. 21x Certified. Blogger, Speaker, and Instructor. DevSecOps Champion
Share this

Leave a review

Excellent

SUBSCRIBE-US

Book a 1:1 Call

Must-read

How to start your AI Journey?

Table of Contents Introduction Are you tired of the same old world? Do you dream of painting landscapes with your code, composing symphonies with data, or...

The Secret Weapon: Prompt Engineering: 🪄

Table of Contents Introduction Crafting the perfect prompt is like whispering secret instructions to your AI muse. But there's no one-size-fits-all approach! Exploring different types of...

How to Singup for your own Production org?

Let's see how we can have our salesforce enterprise Salesforce Org for a 30-day Trial and use it as a Production environment. With the...

Recent articles

More like this

2 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Turn your Salesforce-MuleSoft integration into a seamless journey with this practical guide!How to Configure Salesforce Composite Connector using Mule 4?
5/5

Stuck in coding limbo?

Our courses unlock your tech potential