
Lab 2: Create an Autolaunched Flow for SAP synchronization (Optional)
Overview
-
During this lab you will start from the following Autolaunched Flow draft version to avoid going through repetitive tasks.
-
At the end you will have a fully working flow as follow.
Step 1: Create a copy of the Autolaunched Flow (No Trigger)
-
Login into the Salesforce Developer ORG and access the Setup menĂ¹.
-
Search for
Flows
in the Quick Find text field and clickFlows
under Process Automation. -
Select the
Orchestration Lab’s Flows
list view from the drop down menu in the top left section. -
Click the
LAB - AUTO - Update Order in SAP (Draft)
flow label link from the list. -
Once the flow is opened click the
Save As
button on the top right. -
Select Save as
A New Flow
and provideMy LAB - AUTO - Update Order in SAP
as Flow Label. Click outside the label field and the Flow API Name should appear automatically.Click the
Save
button.
Step 2: Analize the pre-built flow
-
Click on the
Get Order Update CASE
element and clickEdit Element
.As you can see this element is in charge of retrieving the order update case with the
Id
provided as input to the flow with thecaseId
variable. This step is required to retrive the identifier of the order referenced by the case. -
Click
Cancel
to close the window. -
Click on the
Get Salesforce ORDER
element and clickEdit Element
. Looking at the Get Records element configration you can see its goal is to retrieve the order referenced by the case retrieved at the previous step. -
Click
Cancel
to close the window.
Step 3: Add "Set Request Payload" Assignment Flow Element
-
Open the Toolbox with the
Toogle Toolbox
button on the top-left. -
Click
New Resource
to add a new variable. -
Select
Variable
form the drop down list as Resource Type. Compile the remaining fileds as follow.Field Value API Name
requestPayload
Data Type
Apex-Defined
Apex Class
ExternalService__SAPSystemAPI100_putOrders_IN_generated
-
Click
Done
. -
Click the
Add element
button after theGet Salesforce ORDER
element. -
Search for `Assignment' and select it.
-
In the New Assignment modal enter
Set request payload
as Label andSetRequestPayload
as API Name. -
Compile the Variable Values as follow.
Variable Operator Value {!requestPayload.REQx5fDATEx5fH}
Equals
{!sapShippingDate}
{!requestPayload.SALESDOCUMENT}
Equals
{!Get_ORDER.SAP_Id__c}
{!requestPayload.SALESx5fORG}
Equals
3000
{!requestPayload.DISTRx5fCHAN}
Equals
10
{!requestPayload.DIVISION}
Equals
00
{!requestPayload.PURCHx5fNOx5fC}
Equals
9191919
{!requestPayload.SALESx5fDIST}
Equals
2222
-
Click
Done
Step 4: Add "Update SAP Order" Action Flow Element
-
Click the
Add element
button after theSet request payload
element. -
Search for `Action' and select it.
-
In the Action field search for
externalService-SAP
and select the result. -
In the New Action modal enter
Update SAP Order
as Label andUpdateSAPOrder
as API Name. -
In the input value section select the toggle to include the request payload. The generated field should be now editable. In the generated field enter
{!requestPayload}
-
Expand rhe Advanced Section and check the
Manually assign variables
. Enter{!responseCode}
as responseCode. -
Click
Done
Step 5: Add "Update Order Update Case" Update Records Flow Element
-
Click the
Add element
button after theUpdate SAP Order
element. -
Search for
Update Records
and select it. -
In the New Update Records modal enter
Update Order Update CASE
as Label andUpdate_Order_Update_Case
as API Name. -
Select
Specify conditions to identify records, and set fields individually
asHow to Find Records to Update and Set Their Values
. -
Select
Case
as Object. -
Compile filter conditions as follow.
Field Operator Value Id
Equals
{!caseId}
-
Compile field values as follow.
Field Value SAPId__c
{!Get_ORDER.SAP_Id__c}
-
Click
Done
Step 6: Save Autolaunched Flow
-
Click the
Save
button in the top-right corner. -
Click the
Activate
button in the top-right corner.
Step 7: Debug Autolaunched Flow
-
Click the
Debug
button in the top-right corner. -
Enter a valid case id retrieved form the Salesforce org on which you are building the flow. The case must be related to the
Nina Morris
account. Enter one week from today as shipping date. -
Click
Run
-
In the Debug Details right panel expand the
SystemAPI100.putOrders
section and look for the response code. If you see a200
returned as code the flow is working properly.