This applies to Anypoint Studio 7.x
Salesforce Composite Connector can create subject tree, which means it creates multiple Salesforce records which have a relationship between them. This example will create 6 records in Salesforce as below.
<ee:transform doc:name="Transform Message" doc:id="d3d26cef-1082-4449-9d50-5584551be00c" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
{
"sObjectTrees": {
"records": [
{
"Name": "ParentAccount1",
"attributes": {
"objectType": "Account",
"referenceId": "ref4"
},
"ChildAccounts": {
"records": [
{
"Name": "ChildAccount1",
"attributes": {
"objectType": "Account",
"referenceId": "ref5"
}
}
]
},
"Contacts": {
"records": [
{
"LastName": "Contact1",
"attributes": {
"objectType": "Contact",
"referenceId": "ref6"
}
}
]
}
},
{
"Name": "Account2",
"attributes": {
"objectType": "Account",
"referenceId": "ref1"
},
"Contacts": {
"records": [
{
"LastName": "Contact2",
"attributes": {
"objectType": "Contact",
"referenceId": "ref2"
}
},
{
"LastName": "Contact3",
"attributes": {
"objectType": "Contact",
"referenceId": "ref3"
}
}
]
}
}
]
}
}]]></ee:set-payload>
</ee:message>
</ee:transform>
<ee:transform doc:name="Transform the http input for Create SObject Tree"
doc:id="1c05fd08-52b9-48f8-bb8a-5a75ba2cf7fe">
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/java
---
payload.sObjectTrees.records map ((record , indexOfRecord) -> {
"attributes": {
"type": record.attributes.objectType,
"referenceId": record.attributes.referenceId
},
"Name": record.Name,
("ChildAccounts": {
"records": record.ChildAccounts.records map ((record01 , indexOfRecord01) -> {
"attributes": {
"type": record01.attributes.objectType,
"referenceId": record01.attributes.referenceId
},
"Name": record01.Name
})
}),
"Contacts": {
"records": record.Contacts.records map ((record01 , indexOfRecord01) -> {
"attributes": {
"type": record01.attributes.objectType,
"referenceId": record01.attributes.referenceId
},
"LastName": record01.LastName
})
}
})
]]></ee:set-payload>
</ee:message>
</ee:transform>
Disclaimer: This example is provided as a reference for your own usage and is not to be considered a MuleSoft product. This example should be considered as a custom solution. The custom solution is not a Supported MuleSoft product.
Disclaimer: This solution provides a suggestion that should be considered in conjunction with your specific use-case and requirements and does not represent a complete solution for all circumstances.
001117021

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.