1. 13th March 2021 , 11am IST
Hyderabad MuleSoft Meetup
ANYPOINT STUDIO TIPS AND TRICKS & SALESFORCE
COMPOSITE CONNECTOR
2. Agenda
•Introduction Of Organizers and Speakers
•Community Details!
•Anypoint Studio Tips and Tricks by Karthik
•Salesforce Composite Connector by Nitish
•Queries
•Trivia Quiz
2
23. 23
What is ‘Composite’ Connector?
/ˈkɒmpəzɪt/
Adjective: Made up of several parts or elements.
MuleSoft OOTB connector to access Salesforce Composite resources in a
single API Call by minimizing the number of round – trips between client
(MuleSoft) and server (Salesforce instance).
Example: Create an Account and Contact in a single request.
Composite Resources
Composite
Request
Composite
Graphs
Batch sObject Tree
sObject
Collections
25. Composite Request
• Executes a series of REST API requests in a single call
• Response of one request can be used as the input to a next request
• The response bodies and HTTP statuses of the requests are returned in a single response body
• The entire series of requests counts as a single call toward your API limits
Syntax Example
{
"allOrNone": true,
"collateSubrequests": true,
"compositeRequest": [{
Composite
Subrequest
}, {
Composite
Subrequest
}, {
Composite
Subrequest
}]
}
{
"allOrNone": true,
"compositeRequest" : [{
"method" : "POST",
"url" : "/services/data/v51.0/sobjects/Account",
"referenceId" : "refAccount",
"body" : {
"Name" : "Composite Request Account"
}
},{
"method" : "GET",
"url" : "/services/data/v51.0/query/?q=select+id+from+contact+where+lastname='Barr'",
"referenceId" : "refContact"
},{
"method" : "PATCH",
"url" : "/services/data/v51.0/sobjects/Contact/@{refContact.records[0].Id}",
"referenceId" : "refContactUpdated",
"body" : {
"AccountId" : "@{refAccount.id}"
}
}]
}
26. Composite Request (Cont’d)
● Rollback on failure can be specified using:
○ allOrNone Boolean field
○ In case of failure:
■ allOrNone: true (default)
● the entire composite request is rolled back
● The top-level request returns HTTP 200 and includes responses for each subrequest.
■ allOrNone: false
● The remaining subrequests that don’t depend on the failed subrequest are executed.
● Dependent subrequests aren’t executed.
Note: In either case, the top-level request returns HTTP 200 and includes responses for each subrequest.
Response:
27. Question Time!
● What is the default error attribute value ‘allOrNone ’for a composite request?
27
28. Batch
• Executes up to 25 subrequests in a single request.
• The response bodies and HTTP statuses of the subrequests in the batch are returned in a single
response body
• Each subrequest counts against rate limits.
• All subrequests are executed in the context of the same user.
• Subrequests are independent.
• Subrequests execute serially in their order in the request body.
• Error handling:
■ Field: haltOnError
● Default: false
30. Question Time!
● Is a composite batch request synchronous in nature, If yes then why?
30
31. sObject Tree
● Creates one or more sObject trees with root records of the specified type.
● An sObject tree is a collection of nested, parent-child records with a single root
record.
• The request can contain the following:
○ Up to a total of 200 records across all trees
○ Up to five records of different types
○ sObject trees up to five levels deep
38. Comparison Table
Batch Tree Composite Request
Execute a set of subrequests in a single
request.
Execute a set of subrequests in a single
request.
Execute a set of subrequests in a single
request.
Subrequests are executed independently
and information can’t be passed between
subrequest calls
Subrequests are executed dependently
on the root record.
The output of one subrequest can be
used as input to a subsequent
subrequest.
Most ideal to use when there are unrelated
calls, i.e. no relation between subrequests.
Example: Account, A Custom Object with
relation/ no relation to account, Querying
multiple unrelated objects etc.
Most ideal to use when there is a Parent:
Child hierarchy.
Example: Account: Contact, Order:
OrderLineItem, Opportunity:
OpportunityLineItem
Most ideal to use when response from
one request is used for another request.
Example: It could be for a Parent: Child
relationship, or a lookup relationship or
just a simple reference to another record.
It can make up to 25 subrequests in a
single batch call.
It can create a maximum of 200 total
records in a single tree resource call that
can be split across any number of sObject
trees.
It can have 25 subrequests.
Error Attribute: haltOnError
Default: false
Error Attribute: None Error Attribute: allOrNone
Default: true
Note:
1. Do not confuse or use Composite resources/ API instead of any other kind of API which is already built for its most idiomatic usage.
Example: Batch or Bulk API.
2. Composite request can mimic the operation of both batch and tree.
41. Enter Your Full Valid Name (no nick Names are allowed)
Only those who have registered and joined the session will be
allowed!
Goto Mobile Browser
Enter :
kahoot.it