Extract Payload Information to Variables
This section of the tutorial teaches you how to extract information from the payload into different variables to refer to those values later in the flow.
Before You Begin
Complete these procedures:
-
Integrate Salesforce Data into Slack and Email Notifications.
-
Configure your Salesforce integration.
Extract Values From the Payload
-
In Anypoint Code Builder, open your
new-case-salesforce.xml
file. -
Click the (Add component) icon after the On New Case Salesforce component:
-
Type
Transform
and select Transform. -
Configure the Transform Message component to extract data from the payload to variables:
<ee:transform doc:name="Extract Values from Case" > <ee:variables> <ee:set-variable variableName="casestatus"> (1) <![CDATA[%dw 2.0 output application/java --- payload.Status]]> </ee:set-variable> <ee:set-variable variableName="casenumber"> (2) <![CDATA[%dw 2.0 output application/java --- payload.CaseNumber]]> </ee:set-variable> <ee:set-variable variableName="slackchannel"> (3) <![CDATA["this-is-a-test"]]> </ee:set-variable> </ee:variables> </ee:transform>
1 casestatus
retrieves the Salesforce case status: New, Working, or Escalated.2 casenumber
retrieves the case number created by Salesforce.3 Set the slackchannel
to the channel name that you set earlier in the tutorial.
Concatenate Your Values in The Payload
Add a Set Payload component to concatenate the value of your variables in the resulting payload of your application:
-
Click the (Add component) icon after the Transform Message component:
-
Type
set
and select Set Payload. -
Configure the Set Payload component with the following code:
<set-payload doc:name="Set Case Info" value='#["Case Number: " ++ (payload.CaseNumber default "") ++ ", Origin: " ++ (payload.Origin default "") ++ ", Case Type: " ++ (payload.Type default "") ++ ", Priority: " ++ (payload.Priority default "") ++ ", Status: " ++ (payload.Status default "")]'/>
-
Proceed to Add a Condition to Your Flow Logic to create a condition to send an email if the case is escalated or otherwise inform about the case in a Slack channel.