Loading

How To Trigger Assignment Rules In MuleSoft Flow

Data pubblicazione: Apr 3, 2025
Operazione

GOAL

This article explains how to trigger Assignment Rules on Salesforce while creating a Case or Lead record in a Mule Flow.

Fasi

As per the document SOAP API Developer Guide - AssignmentRuleHeader and Salesforce Operations, a header AssignmentRuleHeader needs to be set while creating a Case or Lead record. 


Example

  • In this example, AssignmentRule ID 01Q2v0000016nQeEAI is set while creating a Case record, so that the created Case will be assigned to a specific person or queue on Salesforce.
  • The ID 01Q2v0000016nQeEAI can be retrieved by querying the AssignmentRule object on Salesforce. Alternatively, the ID that starts from 01Q... can be seen in the URL if you login to Salesforce then navigate Setup ==> Service ==> Case Assignment Rule then select a desired Assignment Rule
  • Then AssignmentRuleHeader is set in tag <salesforce:headers>
  • Sample curl request for this example: curl -X POST 'http://localhost:8081/insertCase1' -H 'Content-type: application/json' --data '{"Status": "New", "Origin": "Phone", "Subject": "This is a Test Case"}'
<flow name="insertCase1" >
    <http:listener config-ref="HTTP_Listener_config"
     path="/insertCase1" doc:name="Listener"  />
		<ee:transform doc:name="Transform Message" doc:id="224ba630-c250-4dc7-aa85-cefbc6750d46">
      <ee:message >
        <ee:set-payload ><![CDATA[%dw 2.0
output application/java
---
[{
  Status: payload.Status,
  Origin: payload.Origin,
  Subject: payload.Subject
}]]]></ee:set-payload>
      </ee:message>
    </ee:transform>
		<set-variable value="01Q2v0000016nQeEAI" doc:name="assignmentRuleId" doc:id="0feaadb2-388d-42f7-a6df-e100ff4cbd06" variableName="assignmentRuleId"/>
		<salesforce:create doc:name="Create" type="Case"
     config-ref="Salesforce_Config1">
			<salesforce:headers ><![CDATA[#[%dw 2.0
output application/json
---
{ 
    "AssignmentRuleHeader": { "assignmentRuleId": vars.assignmentRuleId}
}]]]></salesforce:headers>
		</salesforce:create>
    <ee:transform doc:name="Transform Message" doc:id="f1a357f3-66e7-4647-a49b-77f270180223">
      <ee:message >
        <ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload map {
  id:$.id,
  errors:$.errors,
  success:$.success

}]]></ee:set-payload>
      </ee:message>
    </ee:transform>
  </flow>


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.

Numero articolo Knowledge

001116888

 
Caricamento
Salesforce Help | Article