Understanding Salesforce Composite Connector With MuleSoft
Salesforce Composite Connector provides various benefits like simplifying the code, reduce the network overhead by avoiding round trip between MuleSoft and Salesforce, Improve Application performance.
Join the DZone community and get the full member experience.Join For Free
This article will talk about the Salesforce Composite Connector and what are the various operations provided by the Salesforce Composite Connector. It will also talks about what are the different authentication mechanism supported to connect Salesforce and how to configure it.
Salesforce Composite Connector enable you to access various resources, objects or services in the Salesforce using the single API call. It is Anypoint Connector which allows you to use the Salesforce Composite Batch, Request and sObject tree api's.
It provides various benefits like simplifying the code, reduce the network overhead by avoiding round trip between MuleSoft and Salesforce, Improve Application performance.
This connector supports various Authentication mechanism are listed below.
- OAuth v2.0
- OAuth SAML
- OAuth JWT
- OAuth Username and Password
By default, Salesforce Composite Connector is not part of the Mule Palette, so you can installed from the Anypoint Exchange.
Here is the step by step video explaining how to configure the Authentication and installed the connector in the Mule palette.
Composite Request perform series of the rest api's call in single request. You can always use the output of the one request as the input to the subsequent request. Requests in the composite call is known as subrequests. You can have up to 25 subrequest in single call.
It provides a single response which includes all subrequest responses. Top level request always returns HTTP Status Code as "200".
In below request body, there is the 2 subrequests. The first creates the Account in the salesforce and assigned output to the refAccount. The second creates the contact under the new parent Account by referencing the refAccount in the body.
Here is the video tutorial explaining how to configure the Composite Request.
It also support the Transaction by using attribute allOrNone. By default allorNone is false, in case if you want to enable the transaction, you can add allOrNone attribute to true in he request body. This will ensure either all subrequest process successfully or nothing will be committed in case of single or multiple failures.
Here is video tutorial explaining how to configure the Composite Request with Transaction.
Composite Batch allows you to perform up to 25 independent subrequest in the single call. All the subrequests count against the rate limit. The response bodies and HTTP statuses of the subrequests in the batch are returned in a single response body.
Batching for the following resources and resource groups is available in API version 34.0 and later.
- sObject resources—vXX.X/sobjects/
- Connect resources—vXX.X/connect/
- Chatter resources—vXX.X/chatter/
In below request body, there are the 3 subrequests. The first is updating the name in the Account objects. The second is fetching the particular account Name and Billing Postal Code. The third request is sending query to retrieve Id and Name for particular account.
Here is the video tutorial explaining how to configure the Composite Batch.
sObject tree creates one or more sObject trees with root record of the specified type. It is the collection of parent-child, netsed with a single record type. There are few limitations with sObject tree as it allows only 200 records across all the trees, allows up to 5 records of different type and and it is up to 5 level deep.
In below request body, there are 2 account creation request with 2 contact for each account.
Here is the video tutorial explaining how to configure the sObject Tree.
Salesforce Composite Connector is Anypoint Connector which reducing the multiple calls towards Salesforce, avoiding round tripping between MuleSoft and Salesforce, simplifying the code as you don't have to orchestrate the multiple calls towards Salesforce and improve the performance of your applications.
Opinions expressed by DZone contributors are their own.