Skip to content

Latest commit

 

History

History
66 lines (53 loc) · 2.75 KB

File metadata and controls

66 lines (53 loc) · 2.75 KB

Extract Payload Information to Variables

reuse::partial$beta-banner.adoc

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:

Extract Values From the Payload

  1. In Anypoint Code Builder, open your new-case-salesforce.xml file.

  2. Click the (Add component) icon after the On New Case Salesforce component:

    A flow in the canvas UI with the *Add Component* button highlighted
  3. Type Transform and select Transform.

  4. 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:

  1. Click the (Add component) icon after the Transform Message component:

    A flow in the canvas UI with the *Add Component* button highlighted
  2. Type set and select Set Payload.

  3. 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 "")]'/>
  4. Proceed to tut-slack-add-condition-to-your-flow.adoc to create a condition to send an email if the case is escalated or otherwise inform about the case in a Slack channel.