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:
- Select File > New > Mule Project.
- 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:
- In the Mule Palette view, click Search in Exchange.
- In Add Modules to Project, type “Salesforce Composite” in the search box
- Click Salesforce Composite in Available modules.
- Click Add.
- Click Finish.
- 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
- 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:
- In the Mule Palette view, select HTTP > Listener.
- Drag Listener to the Studio canvas.
- On the Listener configuration screen, optionally change the value of the Display Name field.
- Specify a value for the Path field.
- 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.
- On the General tab, specify connection information for the connector.
- Click Test Connection to confirm that Mule can connect with the specified server.
- Click OK.
- Refer below images
Step4 – Add a Composite Connector Operation to the Flow
To add an operation for Salesforce Composite Connector, follow these steps:
- In the Mule Palette view, select Salesforce Composite and then select the pre query operation.
- Drag the operation onto the Studio canvas to the right of the input source.
- 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.
- Select “OAuth JWT” for connection. To configure visit “How to Authenticate Salesforce using JWT from Mulesoft”
- On the General tab, specify connection information for the connector.
- Click Test Connection to confirm that Mule can connect with the specified server.
- 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
- In the Mule Palette view, select Favorites > Transform Message ( core ).
- Drag Transform Message ( core ) to the Studio canvas.
- Use below code
%dw 2.0
output application/json
---
payload
Step6 – Run the Project
- Right-click on the canvas
- Select Run Project “Project Name”
- Hit the URL from the browser or Postman
- See the outcome
Thanks for reading 🙂 Please do like share & Subscribe
#Mule4 #Integration #MuleSoft #SalesforceCompositeConnector
[…] create a Rating Component in Lightning… How to Create and Update dependent picklist values… How to Configure Salesforce Composite Connector using Mule… How to use Lightning Web Component inside Visual… How to integrate Salesforce Platform Event […]
[…] seen how to configure MuleSoft Composer in MuleSoft AnyPoint Studio. If you missed this Here is the Link for […]