DOMRouting Package

Download as pdf or txt
Download as pdf or txt
You are on page 1of 149

Salesforce Order Management

Distributed Order Management


Flow Package User Guide

Winter '22
Revised December 16, 2021

© Copyright 2000–2021 salesforce.com, inc. Salesforce is a registered trademark of salesforce.com, inc., as are other names and
marks. Other marks appearing herein may be trademarks of their respective owners.
Overview
Distributed Order Management Package Overview
What's Included

This package includes sample flows, Apex classes,


custom objects, and custom fields that together
demonstrate a flow-based system for routing order
items to fulfillment locations.

It can handle both delivery orders and Buy Online,


Pick Up in Store (BOPIS) orders -- as well as orders
that combine them both!

3
Distributed Order Management Package Overview
Prerequisites

● Salesforce Order Management enabled


● Salesforce Omnichannel Inventory enabled
● Location Type Populated
○ In Object Manager, open the Location object and add at
least one value to the LocationType picklist; for example,
"Warehouse" or "Retail Store"
● Location Graph Populated & Synced with Omnichannel
Inventory
○ For each location, store its physical address in the Visitor
Address field; include a valid Country and Postal Code
○ For each location and location group, assign an External
Reference ID
○ For each location and location group, set the Should
Sync with OCI field to True

4
Distributed Order Management Package Overview
How Does It Work?

A series of automated flows picks up every new order


summary, determines the set of fulfillment locations
that can most efficiently handle the order's items, and
routes its inventory reservations to those locations.

When the automated process has trouble with an


order, it creates a process exception to notify users of
the issue. An included screen flow allows a user to
manually create fulfillment orders for that order. Then,
a special automated flow picks up those fulfillment
orders and inserts them back into the main process.

5
Distributed Order Management Package Overview
Flowchart of Flows

The next few slides illustrate how the routing flows


process orders.

Each rectangular box represents a flow.

6
Distributed Order Management Package Overview
Flowchart of Flows: Ingest Orders and Schedule Routing

7
Distributed Order Management Package Overview
Flowchart of Flows: Determine Routes for Orders to Ship

8
Distributed Order Management Package Overview
Flowchart of Flows: Create Fulfillment Orders for Unrouted Orders

9
Distributed Order Management Package Overview
Flowchart of Flows: Execute Routing of Orders for Shipping

10
Distributed Order Management Package Overview
Flowchart of Flows: Fulfillment Locations Fulfill Orders

11
Distributed Order Management Package Overview
Flowchart of Flows: Prep & Transfer Back Canceled Order Items for Rerouting

12
Distributed Order Management Package Overview
New in Winter '22: Routing Options

The package offers a choice of default routing logic by


including two versions of the Determine Route flow. Select one
to activate, and leave the other inactive.
● Determine Route by Splits: Choose the available route with the
fewest number of splits. If multiple routes have the fewest
number of splits, pick one arbitrarily.
● Determine Route by Splits and Distance: Choose the available
route with the fewest number of splits. If multiple routes have the
fewest number of splits, pick the one that has the shortest
average distance from its fulfillment locations to the recipient
address.

13
How to Access the DOM Flow Package

To install the package:

1. Log into your Salesforce org.


2. Click this link:
https://login.salesforce.com/packaging/installPackage.apexp?p0=04tB000000
0dWIpIAM
3. Log in with your org credentials.
Custom Objects
and Fields
Included in this Package

15
Custom Objects
For Handling Routing and Fulfillment Data

OCI Interaction Order Summary OCI Interaction Order Item Summary


(AKA Interaction Order) (AKA Interaction Order Item)
Corresponds to a fulfillment order and Corresponds to a fulfillment order item
includes these fields: and includes these fields:
●Reference to the Order Summary ●Reference to the Order Item Summary
●Reference to the Order Delivery Group ●Reference to the OCI Interaction Order Summary
Summary ●Reference to the Fulfillment Order
●Reference to the Fulfillment Order ●Quantity
●Failed Routing Attempt Count ●Origin Location/ Location Group
●Scheduled Date/Time ●Destination Location/ Location Group
●Status (Requested, Succeeded, Failed, or ●No Fulfillment Order Flag
Abandoned) ●Status (Requested, Succeeded, Failed, or
●Type (Routing, Moving, Create, Release) Abandoned)
●Type (Routing, Moving, Create, Release)

16
Custom Objects
For Handling Routing and Fulfillment Data

OCI Interaction Fulfill Order OCI Interaction Fulfill Order Item


(AKA Interaction Fulfillment Order) (AKA Interaction Fulfillment Order Item)
Corresponds to a fulfillment order and Corresponds to a fulfillment order item
includes these fields: and includes these fields:
●Reference to the Fulfillment Order ●Reference to the Fulfillment Order Item
●Scheduled Date/Time ●Reference to the OCI Interaction Fulfill Order
●Status (Requested, Succeeded, Failed, or ●Quantity
Abandoned) ●Origin Location/ Location Group
●Type (Fulfillment, Move, or Cancel) ●Destination Location
●Move/Cancel Flag
●Status
●Type

17
Custom Fields
Added to Standard Objects

Object and Field Description

FulfillmentOrder.Source__c ● Routing - Created by the automated routing process


● No Routing - Created manually or programmatically

FulfillmentOrderLineItem.IncompleteFulfilledQuantity__c Total quantity of associated interaction fulfill order items with


Status REQUESTED and Type FULFILLMENT

FulfillmentOrderLineItem.IncompleteTransferQuantity__c Total quantity of associated interaction fulfill order items with


Status REQUESTED and Is Transfer Move or Transfer
Cancel flag = true

OrderItemSummary.AvailabileToFulfillIncompleteTransferQty__c QuantityOrdered - QuantityCanceled - QuantityAllocated -


IncompleteTransferQuantity__c

OrderItemSummary.IncompleteReleaseQuantity__c Total quantity of associated interaction order items with Status


REQUESTED and Type RELEASE

OrderItemSummary.IncompleteTransferQuantity__c Total quantity of associated interaction order items with Status


REQUESTED, Type TRANSFER_ROUTING, and no
associated fulfillment order

18
Custom Fields
Added to Standard Objects

Object and Field Description

OrderSummary.InventoryTransferAttempts__c Number of associated order summary routing


schedule records

OrderSummaryRoutingSchedule.DeferralCount__c Number of times the order summary routing


schedule has been deferred

OrderSummaryRoutingSchedule.OrderDeliveryGroupSummaryId__c ID of the associated order delivery group summary

OrderSummaryRoutingSchedule.OutboundConnectionFailedAttempts__c Number of times certain invocable action calls


related to the order summary routing schedule have
failed

19
Sample Flows
Routing Flows

Automated Routing Process


• Routing Step 1: Schedule Routing
Note: For ease of reading, this text
• Routing Step 2: Choose one: uses simplified names for some
• Routing Step 2: Determine Route by Splits objects. For example, "order" can refer
to an order summary, or "interaction
• Routing Step 2: Determine Route by Splits and Distance fulfillment order" can refer to an OCI
• Routing Step 3: Execute Routing interaction fulfill order.

• Create Invoice, Ensure Funds If you aren't sure of something, you


can always look at the flow in Flow
• Fulfill Reservation Builder to see the actual object
names.

21
Routing Flows

Non-Automated Fulfillment Order Process


• Create Fulfillment Orders (Screen Flow)
Note: For ease of reading, this text
• Schedule Fulfillment Order Transfer uses simplified names for some
• Create Inventory Reservation objects. For example, "order" can refer
to an order summary, or "interaction
fulfillment order" can refer to an OCI
interaction fulfill order.
Canceled & Partially Fulfilled Fulfillment Order Process
If you aren't sure of something, you
• Prep Fulfillment Order for Transfer Back can always look at the flow in Flow
• Prep Fulfillment Order Item for Transfer Back Builder to see the actual object
names.
• Transfer Back Reservation
• Release Reship Inventory Reservation

22
Routing Step 1: Schedule Routing Flow

This flow runs on each order, processing each of its delivery


groups based on whether its Reserved At Location is a
location or a location group:
● Location: The delivery group's items are considered to
be Buy Online, Pick Up In Store (BOPIS). The flow
creates fulfillment orders for them.
● Location Group: The flow schedules the delivery
group's items for transfer to specific fulfillment
locations.

23
Flow:
Routing Step 1: Schedule Routing

Assume
BOPIS;
Location
Create
Fulfillment
Order

Check Each
Delivery
New Order Group's
Reservation
Location Type

Assume
Shipping;
Location
Create
Group
Routing
Schedule

24
Flow:
Routing Step 1: Schedule Routing
When does it run?

● Runs on every order summary


● Triggered by the Order Summary Created event
● Requirements:
○ Every order item summary (except delivery charges)
must have its Reserved At Location set
○ Every referenced location and location group must be
synchronized with Omnichannel Inventory

25
Flow:
Routing Step 1: Schedule Routing
1. Get Order Item Summaries

First, the flow traverses the order delivery groups associated


with the order.

For each delivery group, it starts by getting all the data for the
group's items that represent products. (It'll deal with any
delivery charges later on.)

26
Flow:
Routing Step 1: Schedule Routing
2. Check Reserved At Data
The flow then loops through the products in the current
delivery group.

First, it checks whether any of them have already caused


errors. (Not an issue for the first product!) If so, it just skips
to the next one, and continues skipping through the rest of
the current delivery group's products.

Next, the flow verifies that the current product's Reserved


At Location is set. If not, it creates a process exception, flags
the error, and skips the rest of the delivery group's products.

The flow then records the fulfillment location, if needed.

27
Flow:
Routing Step 1: Schedule Routing
3. Record Fulfillment Location or Location Group
If the flow already stored the current group's Reserved At
Location, it verifies that the current product's Reserved At
Location matches. If not, it creates a process exception and
errors out of the product-processing loop.

If this is the first product in the delivery group, the flow


checks whether its Reserved At Location is a location or a
location group. That's stored as the delivery group's
Location or Location Group, accordingly.

The flow then verifies that the assigned location or location


group is synced with Omnichannel Inventory. If not, then
you guessed it -- a shiny new process exception and no
more fun for the current delivery group.
28
Flow:
Routing Step 1: Schedule Routing
4. Add BOPIS Products to Fulfillment Group Input
The last step in the product loop only applies to BOPIS products. If the delivery
group's original fulfillment location is a specific location (as opposed to a location
group), then the flow considers it to be BOPIS, and adds the current product to an
input record for creating a fulfillment order later.

Note: How does the flow determine whether the record ID in the Reserved At
Location field references a location or a location group? It checks the first three
digits of the ID, which identify the object type -- for a location, that's 131. A pretty
neat trick!

29
Flow:
Routing Step 1: Schedule Routing
5. Add Shipping Delivery Group to Routing List
Once the flow finishes looping through the
products in the current delivery group, it checks
whether the Reserved At Location is a location or
a location group. If it's a location group, the flow
considers the delivery group to be for shipping
and adds it to a routing list, then moves to the
next delivery group in the order.

Later, the flow will create a routing schedule for


each delivery group in the routing list.

If the Reserved At Location is a location, signalling


BOPIS, the Flow has one more thing to do with
the current delivery group.
30
Flow:
Routing Step 1: Schedule Routing
6. Finalize BOPIS Fulfillment Order Input
If the delivery group is BOPIS, then the flow
retrieves any of its items that represent delivery
charges, and adds them to the fulfillment order
input.

Finally, it adds the fulfillment order input to a list


of inputs that it'll use later to create fulfillment
orders for all the BOPIS purchases in the order.

31
Flow:
Routing Step 1: Schedule Routing
7. Create BOPIS Fulfillment Orders
After the flow loops through all the delivery groups in the
order, it calls the Create Fulfillment Order invocable action
for each BOPIS fulfillment order input.

Since these fulfillment orders don’t need to be processed


by the Schedule Fulfillment Order Transfer flow, we set
their Source__c fields to ROUTING.

When a location fulfills a BOPIS order, a user should


update the fulfillment order's status to Fulfilled. That
triggers the Create Invoice, Ensure Funds flow.

32
Flow:
Routing Step 1: Schedule Routing
8. Create Routing Schedules for Shipping Delivery Groups
Finally, the flow creates an order summary routing schedule for each delivery group in its
routing list. It sets the following values on each routing schedule:
● Status: SCHEDULED
● ScheduledDatetime: current DateTime

The creation of each order summary routing


schedule triggers the Routing Step 2:
Determine Routing flow.

33
Routing Step 2: Determine Route by Splits
(Reminder: Choose and activate one of the two versions of this flow.)
This flow runs on each order summary routing schedule. It
gets the associated order delivery group and creates an
interaction order and interaction order items for it.
It determines the best fulfillment route based on minimizing
the number of splits.
Remember that this package adds a custom field to the Order
Summary Routing Schedule object that references an order
delivery group summary. A standard routing schedule isn't
associated with a specific delivery group.

34
Flow:
Routing Step 2: Determine Route by Splits

Find Best For each Route


Order Order Get Fulfillment Location:
Routing Delivery Inventory Route Create
Schedule Group Availability (Fewest Interaction
Splits) Order & Items

35
Flow:
Routing Step 2: Determine Route by Splits
When does it run?

● Runs on each order summary routing schedule with its


ScheduleStatus field set to SCHEDULED
● Triggered when a routing schedule is created or
updated
● Runs at the routing schedule's ScheduledDatetime

36
Flow:
Routing Step 2: Determine Route by Splits
1. Get Order Delivery Group Data
First, the flow gets the order and order delivery group associated with the routing schedule.

Next, it'll determine which, if any, items in the delivery group need to be routed. The package
provides some custom fields on Order Item Summary to help with that.

37
Flow:
Routing Step 2: Determine Route by Splits
2. Identify Items to Route
The flow needs to identify any item quantities that haven't already been routed. This package
adds a couple of custom fields to Order Item Summary to help with that:
● IncompleteTransferQuantity__c: Quantity of the order item already included in
interaction order items, but not yet allocated to fulfillment orders
● AvailableToFulfillIncompleteTransferQty__c: QuantityOrdered - QuantityCanceled -
QuantityAllocated - IncompleteTransferQuantity__c

The flow traverses the delivery group and makes a routing list of order items with a nonzero
AvailableToFulfillIncompleteTransferQty__c field. If the list is empty, then the flow exits.

38
Flow:
Routing Step 2: Determine Route by Splits
3. Limit Processing Rate
After initializing some variables, the flow calls a
custom Apex action that protects it against data
overload. If the flow is trying to process too many
concurrent routing schedules, it can defer the
current routing schedule to be processed later.

If the action decides to defer the routing schedule,


the flow reschedules the routing schedule for one
minute later and increments a custom counter field
that tracks the number of times it's been deferred.

39
Flow:
Routing Step 2: Determine Route by Splits
4a. Get Inventory Availability
The next step is to retrieve inventory
availability data for the items to be routed.

The Flow loops through the items on the list,


and adds each one to a new list. It'll use this
list later, when it calls the Find Routes action.

If an item represents a delivery charge, then


the flow can skip to the next item.

Otherwise, the flow retrieves the item's


assigned location group, adds it to a list, and
builds an input for the Get Availability
invocable action.
40
Flow:
Routing Step 2: Determine Route by Splits
4b. Get Inventory Availability
The flow then calls the Omnichannel Inventory Get Availability
invocable action for the item at its assigned location group.

If the action call fails, and the failure limit hasn't been reached, the
routing schedule is rescheduled. Its new time is a number of hours in
the future equal to its number of action call failures plus one.

If the failure limit is reached, then the flow creates a process exception
using the fault response, sets the routing schedule's ScheduleStatus to
ABANDONED, and increments the order's RoutingAttempts.

This action uses a failure limit of 2. The flow abandons the routing
schedule if the action call fails a third time.

41
Flow:
Routing Step 2: Determine Route by Splits
4c. Get Inventory Availability
If the action call doesn't return any available inventory, then
the flow treats it the same as a failed action call. The only
difference is the text of the process exception Message.

If the Get Availability call returns a valid availability response,


then the flow adds the response to a list and loops to the
next item to be routed.

42
Flow:
Routing Step 2: Determine Route by Splits
5a. Find Routes with Fewest Splits
The flow now builds an action input using the item quantities to be fulfilled and the
inventory availability responses. The action will use the availability data to determine the
routes, or sets of fulfillment locations, that can most efficiently handle the requested
quantities.

The flow sets the input's maximum number of splits to 2. You can think of a split as an
additional fulfillment location beyond the first. So a fulfillment route with 2 splits includes
3 locations. Thus, limiting routes to two splits tells the action to only return routes that
involve 3 or fewer fulfillment locations.

43
Flow:
Routing Step 2: Determine Route by Splits
5b. Find Routes with Fewest Splits
The flow then calls the Find Routes with Fewest Splits action.

If the action call fails, or doesn't return a valid response, then the flow
creates a process exception, sets the routing schedule's
ScheduleStatus to ABANDONED, and increments the order's
RoutingAttempts.

If the action call failed, the flow copies the fault response to the
process exception's Message field.

If the action ran, but didn't return a valid response, the flow records
that fact in the process exception's Message field.

44
Flow:
Routing Step 2: Determine Route by Splits
5c. Find Routes with Fewest Splits
If the action call doesn't return any routes, then the flow checks how
many routing attempts, both failed and successful, have been made for
the order summary associated with the current routing schedule.

If the routing attempt limit hasn't been reached, then the routing
schedule is rescheduled for one day in the future.

If the flow receives an empty Find Routes response after the fourth
routing attempt, then it treats the empty response the same as it treats
an invalid response, and abandons the routing schedule.

Be aware that the count includes attempts made for other routing
schedules associated with the same order summary!

45
Flow:
Routing Step 2: Determine Route by Splits
5d. Find Routes with Fewest Splits
If the action call returns more than one valid route, the response orders them by number
of splits, with the fewest splits first. So the flow just takes the first route from the response.

46
Flow:
Routing Step 2: Determine Route by Splits
6a. Create Interaction Orders
Next, the flow sets up inputs for creating the interaction orders. Because an interaction order
uses data from several different records, the flow calls a custom Apex action that helps
prepare the inputs.

Remember that an interaction order corresponds to a fulfillment order, so an order delivery


group can involve multiple interaction orders.

47
Flow:
Routing Step 2: Determine Route by Splits
6b. Create Interaction Orders
The flow then loops through the locations in the selected route, creating an interaction order
input for each one. It sets the following values:
● Status__c: REQUESTED
● Type__c: TRANSFER_ROUTING
● Schedule__c: Current DateTime

They tell the Routing Step 3 flow to process


these interaction orders as soon as possible.

The flow adds each input to a list, then uses


The list to create the interaction orders.

48
Flow:
Routing Step 2: Determine Route by Splits
7a. Create Interaction Order Items
The next step is to create the interaction order items. To set up the
inputs, the flow loops through the locations in the route.

It uses a counter to match each location with an interaction order, as


we'll see shortly.

After incrementing the location counter, the flow gets the list of items
to route to the current location.

49
Flow:
Routing Step 2: Determine Route by Splits
7b. Create Interaction Order Items
The flow then loops through the interaction orders, using
the location counter to select the one in the same list
position.

For example, the first time through the loop, it selects the
first route location and the first interaction order. That first
interaction order handles the items being routed to that
first location. The second interaction order handles the
items going to the second location, and so on.

50
Flow:
Routing Step 2: Determine Route by Splits
7c. Create Interaction Order Items
Then the flow loops through the items being routed to the current location, building
inputs for them using the current target location and selected interaction order.

As with the interaction orders, it sets the Status__c to REQUESTED and the Type__c to
TRANSFER_ROUTING.

51
Flow:
Routing Step 2: Determine Route by Splits
7d. Create Interaction Order Items
After looping through the route's locations and preparing all the interaction order item
inputs, the flow creates them. Now everything's ready for the Routing Step 3: Execute
Routing flow.

Finally, it sets the routing schedule's ScheduleStatus to COMPLETED and increments the
number of routing attempts made for the original order summary.

Remember that a successful routing attempt counts toward the limit if a later routing
attempt for another part of the same order fails.

52
Routing Step 2: Determine Route by Splits and
Distance
(Reminder: Choose and activate one of the two versions of this flow.
This version is available in Winter '22 and later, and requires each
location to have a Visitor Address with a valid Country and Postal
Code.)
This flow runs on each order summary routing schedule. It
gets the associated order delivery group and creates an
interaction order and interaction order items for it.
It determines the best fulfillment route based on minimizing
the number of splits and the average delivery distance.
Remember that this package adds a custom field to the Order
Summary Routing Schedule object that references an order
delivery group summary. A standard routing schedule isn't
associated with a specific delivery group.
53
Flow: Routing Step 2:
Determine Route by Splits and Distance

Find Best
Fulfillment For each Route
Order Order Get Route Location:
Routing Delivery Inventory (Fewest Splits Create
Schedule Group Availability & Shortest Interaction
Average Order & Items
Distance)

54
Flow: Routing Step 2:
Determine Route by Splits and Distance
When does it run?

● Runs on each order summary routing schedule with its


ScheduleStatus field set to SCHEDULED
● Triggered when a routing schedule is created or
updated
● Runs at the routing schedule's ScheduledDatetime

55
Flow: Routing Step 2:
Determine Route by Splits and Distance
1. Get Order Delivery Group Data
First, the flow gets the order and order delivery group associated with the routing schedule.

Next, it'll determine which, if any, items in the delivery group need to be routed. The package
provides some custom fields on Order Item Summary to help with that.

56
Flow: Routing Step 2:
Determine Route by Splits and Distance
2. Identify Items to Route
The flow needs to identify any item quantities that haven't already been routed. This package
adds a couple of custom fields to Order Item Summary to help with that:
● IncompleteTransferQuantity__c: Quantity of the order item already included in
interaction order items, but not yet allocated to fulfillment orders
● AvailableToFulfillIncompleteTransferQty__c: QuantityOrdered - QuantityCanceled -
QuantityAllocated - IncompleteTransferQuantity__c

The flow traverses the delivery group and makes a routing list of order items with a nonzero
AvailableToFulfillIncompleteTransferQty__c field. If the list is empty, then the flow exits.

57
Flow: Routing Step 2:
Determine Route by Splits and Distance
3. Limit Processing Rate
After initializing some variables, the flow calls a
custom Apex action that protects it against data
overload. If the flow is trying to process too many
concurrent routing schedules, it can defer the
current routing schedule to be processed later.

If the action decides to defer the routing schedule,


the flow reschedules the routing schedule for one
minute later and increments a custom counter field
that tracks the number of times it's been deferred.

58
Flow: Routing Step 2:
Determine Route by Splits and Distance
4a. Get Inventory Availability
The next step is to retrieve inventory
availability data for the items to be routed.

The Flow loops through the items on the list,


and adds each one to a new list. It'll use this
list later, when it calls the Find Routes action.

If an item represents a delivery charge, then


the flow can skip to the next item.

Otherwise, the flow retrieves the item's


assigned location group, adds it to a list, and
builds an input for the Get Availability
invocable action.
59
Flow: Routing Step 2:
Determine Route by Splits and Distance
4b. Get Inventory Availability
The flow then calls the Omnichannel Inventory Get Availability
invocable action for the item at its assigned location group.

If the action call fails, and the failure limit hasn't been reached, the
routing schedule is rescheduled. Its new time is a number of hours in
the future equal to its number of action call failures plus one.

If the failure limit is reached, then the flow creates a process exception
using the fault response, sets the routing schedule's ScheduleStatus to
ABANDONED, and increments the order's RoutingAttempts.

This action uses a failure limit of 2. The flow abandons the routing
schedule if the action call fails a third time.

60
Flow: Routing Step 2:
Determine Route by Splits and Distance
4c. Get Inventory Availability
If the action call doesn't return any available inventory, then
the flow treats it the same as a failed action call. The only
difference is the text of the process exception Message.

If the Get Availability call returns a valid availability response,


then the flow adds the response to a list and loops to the
next item to be routed.

61
Flow: Routing Step 2:
Determine Route by Splits and Distance
5a. Find Routes with Fewest Splits
The flow now builds an action input using the item quantities to be fulfilled and the
inventory availability responses. The action will use the availability data to determine the
routes, or sets of fulfillment locations, that can most efficiently handle the requested
quantities.

The flow sets the input's maximum number of splits to 2. You can think of a split as an
additional fulfillment location beyond the first. So a fulfillment route with 2 splits includes
3 locations. Thus, limiting routes to two splits tells the action to only return routes that
involve 3 or fewer fulfillment locations.

62
Flow: Routing Step 2:
Determine Route by Splits and Distance
5b. Find Routes with Fewest Splits
The flow then calls the Find Routes with Fewest Splits action.

If the action call fails, or doesn't return a valid response, then the flow
creates a process exception, sets the routing schedule's
ScheduleStatus to ABANDONED, and increments the order's
RoutingAttempts.

If the action call failed, the flow copies the fault response to the
process exception's Message field.

If the action ran, but didn't return a valid response, the flow records
that fact in the process exception's Message field.

63
Flow: Routing Step 2:
Determine Route by Splits and Distance
5c. Find Routes with Fewest Splits
If the action call doesn't return any routes, then the flow checks how
many routing attempts, both failed and successful, have been made for
the order summary associated with the current routing schedule.

If the routing attempt limit hasn't been reached, then the routing
schedule is rescheduled for one day in the future.

If the flow receives an empty Find Routes response after the fourth
routing attempt, then it treats the empty response the same as it treats
an invalid response, and abandons the routing schedule.

Be aware that the count includes attempts made for other routing
schedules associated with the same order summary!

64
Flow: Routing Step 2:
Determine Route by Splits and Distance
6a. Find Route with Shortest Average Distance
Now, the flow compares all valid routes to find the one with the shortest average delivery
distance. For each route, it does the following:
1. For each fulfillment location in the route, calculate the distance to the recipient address in miles.
2. Calculate the average delivery distance by adding the distances and dividing the total by the
number of fulfillment locations in the route.
Then, it compares the average distances of all the routes and selects the route with the
shortest average.

The first step is to create an action input with the list of routes and the recipient address.

65
Flow: Routing Step 2:
Determine Route by Splits and Distance
6b. Find Route with Shortest Average Distance
The flow then calls the Rank Locations by Distance action.

If the action call fails, and the failure limit of two hasn't been reached,
the routing schedule is rescheduled. Its new time is a number of hours
in the future equal to its number of action call failures plus one.

If the action call fails for a third time, or if it succeeds but doesn't
return a valid response, then the flow creates a process exception with
an appropriate message, sets the routing schedule's ScheduleStatus to
ABANDONED, and increments the order's RoutingAttempts.

66
Flow: Routing Step 2:
Determine Route by Splits and Distance
6c. Find Route with Shortest Average Distance
If the Rank Locations action returns a valid response, the flow checks the number of
routes included in the response.

If no valid routes were returned, it creates a process exception with an appropriate


message, sets the routing schedule's ScheduleStatus to ABANDONED, and increments
the order's RoutingAttempts.

67
Flow: Routing Step 2:
Determine Route by Splits and Distance
6d. Find Route with Shortest Average Distance
If the Rank Locations action returns any valid routes, it
assigns them ranks based on the average distances
between each of the route's locations and the recipient
address.

The flow selects the returned route with Rank=1, and


adds each of its locations to the list of locations to be
included in the fulfillment.

68
Flow: Routing Step 2:
Determine Route by Splits and Distance
7a. Create Interaction Orders
Next, the flow sets up inputs for creating the interaction orders. Because an interaction order
uses data from several different records, the flow calls a custom Apex action that helps
prepare the inputs.

Remember that an interaction order corresponds to a fulfillment order, so an order delivery


group can involve multiple interaction orders.

69
Flow: Routing Step 2:
Determine Route by Splits and Distance
7b. Create Interaction Orders
The flow then loops through the locations in the selected route, creating an interaction order
input for each one. It sets the following values:
● Status__c: REQUESTED
● Type__c: TRANSFER_ROUTING
● Schedule__c: Current DateTime

They tell the Routing Step 3 flow to process


these interaction orders as soon as possible.

The flow adds each input to a list, then uses


The list to create the interaction orders.

70
Flow: Routing Step 2:
Determine Route by Splits and Distance
8a. Create Interaction Order Items
The next step is to create the interaction order items. To set up the
inputs, the flow loops through the locations in the route.

It uses a counter to match each location with an interaction order, as


we'll see shortly.

After incrementing the location counter, the flow gets the list of items
to route to the current location.

71
Flow: Routing Step 2:
Determine Route by Splits and Distance
8b. Create Interaction Order Items
The flow then loops through the interaction orders, using
the location counter to select the one in the same list
position.

For example, the first time through the loop, it selects the
first route location and the first interaction order. That first
interaction order handles the items being routed to that
first location. The second interaction order handles the
items going to the second location, and so on.

72
Flow: Routing Step 2:
Determine Route by Splits and Distance
8c. Create Interaction Order Items
Then the flow loops through the items being routed to the current location, building
inputs for them using the current target location and selected interaction order.

As with the interaction orders, it sets the Status__c to REQUESTED and the Type__c to
TRANSFER_ROUTING.

73
Flow: Routing Step 2:
Determine Route by Splits and Distance
8d. Create Interaction Order Items
After looping through the route's locations and preparing all the interaction order item
inputs, the flow creates them. Now everything's ready for the Routing Step 3: Execute
Routing flow.

Finally, it sets the routing schedule's ScheduleStatus to COMPLETED and increments the
number of routing attempts made for the original order summary.

Remember that a successful routing attempt counts toward the limit if a later routing
attempt for another part of the same order fails.

74
Routing Step 3: Execute Routing Flow

This flow processes interaction orders. It performs two main


functions for each one:
● Transfers the inventory reservations from location groups
to locations.
● Creates a fulfillment order if needed.
○ A non-BOPIS interaction order created by the Routing
Step 2: Determine Route flow needs a fulfillment order.
○ A BOPIS interaction order already has a fulfillment order
(created by the Routing Step 1: Schedule Routing flow).
○ An interaction order created by the Schedule Fulfillment
Order Transfer flow was, as you might guess from the
name, created for an existing fulfillment order.

75
Flow:
Routing Step 3: Execute Routing

Create
No
Fulfillment
Order

Transfer
Interaction
Inventory
Interaction Order
Reservations
Order from Associated
from
Routing with a
Location
Process Fulfillment
Groups to
Order?
Locations

Yes

76
Flow:
Routing Step 3: Execute Routing
When does it run?

● Runs on interaction orders created by one of the


package flows
● Triggered when an interaction order is created or
updated with the following values:
○ Status__c: REQUESTED
○ Type__c: TRANSFER_ROUTING
● Processes the interaction order at the datetime of its
Schedule field

77
Flow:
Routing Step 3: Execute Routing
1. Get Transfer Data for Interaction Order Items
First, the flow loops through the interaction order
items belonging to the interaction order.

For each one that isn't a delivery charge, the flow


creates a transfer input record with its source location
group and target location.

It adds the transfer inputs to a list for consumption


by the OCI Transfer Reservation invocable action.

78
Flow:
Routing Step 3: Execute Routing
2a. Transfer Inventory Reservations
The flow then passes the list of transfer inputs to the OCI Transfer Reservation invocable
action, along with these values:
● All or Nothing flag = true
● Priority = number of routing schedules associated with the original order summary

The All or Nothing flag tells the action to roll back all of the transfers if any of them fail.

When the action runs on inputs from multiple sources, it


processes the transfers in descending Priority order. So if the
action receives transfers for an order that's been rescheduled
twice, and transfers for an order on its first try, it'll process the
rescheduled order's transfers first.

79
Flow:
Routing Step 3: Execute Routing
2b. Transfer Inventory Reservations
If the action call fails, and the failure limit hasn't been reached,
the interaction order is rescheduled to be processed again in one
minute.

If the failure limit is reached, then the flow creates a process


exception and sets the interaction order's Status__c to
ABANDONED.

This flow uses a failure limit of 4. It abandons the interaction


order if the action call fails a fifth time.

80
Flow:
Routing Step 3: Execute Routing
2c. Transfer Inventory Reservations
If the OCI Transfer Inventory action succeeds, but returns
any errors, the flow sets the interaction order's Status__c
to COMPLETED_FAIL and creates a new order summary
routing schedule.

The routing schedule's Scheduled DateTime is set to one


minute in the future. That causes the Routing Step 2:
Determine Route flow to run again for the associated
order summary. That flow will create new interaction
orders for it, and hopefully they'll make it through step 3
next time!

81
Flow:
Routing Step 3: Execute Routing
3. Check for Fulfillment Order
After successfully transferring the inventory reservations from location groups to
locations, the flow checks whether the interaction order is associated with an
existing fulfillment order.

If so, then this flow's work is done! It finishes by setting the


interaction order's Status__c to COMPLETED_SUCCEED.

If not, then it's time to create a fulfillment order.

Remember: If the interaction order came from the Routing Step 2:


Determine Route flow, and it isn't BOPIS, then it needs a new
fulfillment order.

82
Flow:
Routing Step 3: Execute Routing
4. Prepare Fulfillment Order Inputs
The flow loops through the interaction
order's items and creates fulfillment
order input records for them.

It also checks all the items that aren't


delivery charges, to verify that they all
have the same fulfillment location.

If any products have mismatched


locations, the flow creates a process
exception and sets the interaction
order's status to ABANDONED.

83
Flow:
Routing Step 3: Execute Routing
5. Create Fulfillment Order
Finally, it's time to call the Create
Fulfillment Order invocable action.

If the action fails, the flow creates a


process exception and reschedules the
interaction order to be processed again
in one minute.

If the action succeeds, then the flow


sets the interaction order's Status__c to
COMPLETED_SUCCEED. It also sets the
fulfillment order's Source__c to ROUTING.
That tells the Schedule Fulfillment
Order Transfer flow not to process
this fulfillment order.
84
Create Invoice, Ensure Funds Flow

This flow performs two separate tasks:


● Creates an interaction fulfillment order and fulfillment
order items based on the standard fulfillment order and
fulfillment order items.
● Creates an invoice for the fulfillment order, then ensures
funds and applies them to it.

Create
Ensure
Fulfillment Interaction
Funds and
Order with Fulfillment Create
Apply Them
Status Order & Invoice
to the
Fulfilled Items for
Invoice
Routing

85
Flow:
Create Invoice, Ensure Funds
When does it run?

● Runs on a fulfillment order that's been closed


○ Manually, such as by a user at a fulfillment location
○ Programmatically, such as by an API as part of an automated ASN process
● Triggered by the Fulfillment Order Status Changed event
● Processes the fulfillment order if its new Status is Fulfilled

86
Flow:
Create Invoice, Ensure Funds
1. Create Interaction Fulfillment Order
First, the flow creates an interaction fulfillment order for the fulfillment order, and sets these
values:
● Status__c: REQUESTED
● Type__c: FULFILLMENT
● Schedule__c: Current DateTime
Creating the record with the values REQUESTED and FULFILLMENT triggers the Fulfill
Reservation flow, and the Schedule__c tells that flow when to run. But this flow isn't done yet!

87
Flow:
Create Invoice, Ensure Funds
2. Create Interaction Fulfillment Order Items
The flow then creates an interaction fulfillment order item
for each fulfillment order line item in the fulfillment order
that represents a product.

It sets either the source location or the source location


group, based on where the associated order item is
currently reserved.

88
Flow:
Create Invoice, Ensure Funds
3. Create Invoice
Next, the flow calls the Create Invoice invocable action for the
fulfillment order.

The action derives the invoice amounts from the fulfillment


order amounts, which were themselves derived from the
amounts on the order items associated with it.
If the fulfillment order is for a reshipment, the amount is zero.

If the action fails, the flow creates a process exception with an


appropriate message.

89
Flow:
Create Invoice, Ensure Funds
4. Check Invoice Balance
If the fulfillment order is for a reshipment, then the invoice has a zero balance, and the flow
doesn't need to ensure funds for it. So the flow checks the new invoice's balance.

If the balance is zero, then the flow is finished. Otherwise, it adds the invoice information to
an input for the Ensure Funds invocable action.

The action only requires the order summary and fulfillment order IDs as input, but the
fulfillment order ID must be wrapped in an Apex-defined input representation.

90
Flow:
Create Invoice, Ensure Funds
5. Ensure Funds
If the invoice has a balance, the flow calls the Ensure Funds
invocable action.

All that's left now is to fulfill the inventory reservations used for
this order. That's handled by the Fulfill Reservation flow, which this
flow already triggered by creating an interaction fulfillment order.

91
Fulfill Reservation Flow

This flow collects fulfillment data for an interaction


fulfillment order, then calls the OCI Fulfill Reservation action
using that data as input.

Call OCI
Interaction Collect
Fulfill Update
Fulfillment Fulfillment
Reservation Records
Order Data
Action

92
Flow:
Fulfill Reservation
When does it run?

● Runs on every interaction fulfillment order created by the routing process


● Triggered when an interaction fulfillment order is created or updated
● Processes the interaction fulfillment order at the time of its Schedule__c if it has these
values:
○ Status__c: REQUESTED
○ Type__c: FULFILLMENT

93
Flow:
Fulfill Reservation
1. Get Inventory Reservations
First, the flow traverses the interaction fulfillment order
items belonging to the interaction fulfillment order,
and retrieves their inventory reservation details.
To retrieve an item's SKU, it first looks up the
associated fulfillment order item, then uses that to find
the associated order item summary.

94
Flow:
Fulfill Reservation
1. Get Inventory Reservations (continued)
The flow builds an OCI Fulfill Reservation action input for each interaction fulfillment order
item using the following data:

● actionRequestId: ID of the interaction fulfillment order item


● externalRefId: Name of the interaction fulfillment order item
● locationIdentifier: ExternalReference of the location referenced by the
FulfilledFromLocationId on the fulfillment order associated with the interaction fulfillment
order
● quantity: ID of the interaction fulfillment order item
● stockKeepingUnit: StockKeepingUnit of the order item summary associated with the
fulfillment order item associated with the interaction fulfillment order item

95
Flow:
Fulfill Reservation
2. Call OCI Fulfill Reservation Action
If the flow retrieved any reservation data, it passes the inputs to the OCI Fulfill Reservation
invocable action.

96
Flow:
Fulfill Reservation
3a. Update Records (Action Failure)
If the action fails, the flow compares the current value of the
interaction fulfillment order's ConnectionFailedAttempts__c to
the flow variable MaxOCIConnectionFailAttempts (default value:
3), and does the following:
● If the number of failed attempts is less than the maximum,
increment ConnectionFailedAttempts__c
● If the number of failed attempts is equal to or greater than
the maximum:
○ Set the interaction fulfillment order's Status__c to
ABANDONED
○ Create a process exception for the associated order
summary, setting the Message field to "The number of
unsuccessful attempts to send transfer requests to
Omnichannel Inventory has reached the limit."

97
Flow:
Fulfill Reservation
3b. Update Records (Fulfillment Success)
If the action runs, and returns a success value of true, the flow sets the interaction fulfillment
order's Status__c to COMPLETED_SUCCEED.

98
Flow:
Fulfill Reservation
3c. Update Records (Fulfillment Failure)
If the action runs, but returns a success value of false, the flow
does the following:
● For each error property in the returns, create a process
exception for the associated order summary, copying the
Message field from the returned error property to the
process exception's Message field
● Set the interaction fulfillment order's Status__c to
COMPLETED_FAIL

99
Create Fulfillment Orders Screen Flow

This flow creates fulfillment orders for an order summary that


errored out of the Routing Step 1: Schedule Routing flow or
the Routing Step 2: Determine Routing flow.
Users can monitor process exceptions to be notified when the
flows fail to handle an order.
When an order requires human intervention, a user runs this
flow from the Actions & Recommendations component on
the order summary's details page.
Note: If this flow encounters an error, it doesn't create a
process exception. It just notifies the user interacting with it
by presenting an error message.
100
Screen Flow:
Create Fulfillment Orders
Screen Flow Stages
This flow has five stages, each corresponding to a screen that a user interacts with.
Two of the stages are optional, depending on the number of delivery groups and
the presence of delivery charges.
Stage 1: Stage 4:
Yes Select Select
Yes
Delivery Delivery
Group Charges

Multiple Stage 3: Stage 5:


Stage 2: Any
Delivery Select Confirm
Select Delivery
Groups to Fulfillment Fulfillment
Products Charges?
Fulfill? Locations Orders

No No

101
Screen Flow:
Create Fulfillment Orders
1. (User) Launch Flow
This flow is a screen flow, launched by a user from the UI. Before
you can use it, add it to the Actions & Recommendations
component of the Order Summary details page layout.

To run this flow, navigate to the details page for the order
summary that requires intervention, and launch the flow from the
Actions & Recommendations menu.

The flow can only process a managed order summary. Once it


verifies that the order summary is valid, it retrieves the associated
order delivery group summaries.

102
Screen Flow:
Create Fulfillment Orders
2. Retrieve Delivery Groups
The flow traverses the delivery groups, recording any that contain products to be fulfilled.
The next step depends on how many delivery groups are in need of fulfillment.

If it doesn't find any,


the flow exits with an
error.

103
Screen Flow:
Create Fulfillment Orders
3. Select Delivery Group to Fulfill
If the flow only finds one delivery group to fulfill, it
skips the delivery group selection screen and
automatically selects the single delivery group for
fulfillment.

If it finds more than one, it initializes all five flow


stages, then presents stage 1, the delivery group
selection screen. After the user selects one, the flow
continues.

104
Screen Flow:
Create Fulfillment Orders
4. Select Products
Next, the flow retrieves the products and
delivery charges belonging to the selected
delivery group.

Then it sets up the remaining stages. It


always includes stages 2, 3, and 5, but only
needs stage 4 if there are delivery charges.

The flow then presents stage 2, the product


selection screen. After the user selects the
products to fulfill, the flow continues.

105
Screen Flow:
Create Fulfillment Orders
5. Retrieve Locations
On to stage 3, fulfillment location selection.

The flow prepares by retrieving lists of all location


groups and locations in the system, stopping with an
error if it doesn't find at least one of each.

It then collects all of the location group assignments,


which define the location group that each location
belongs to (if any).

106
Screen Flow:
Create Fulfillment Orders
6. Select Fulfillment Locations
The flow then loops through the selected products and builds
a list of inputs it'll use later to create fulfillment order items for
them.

After that, it presents stage 3, the location selection screen.


There, the user assigns a fulfillment location to each product.

107
Screen Flow:
Create Fulfillment Orders
7. Decide Shipping Charge Inclusion
If the selected delivery group has any delivery charges, the flow presents stage 4, the include
delivery charges selection screen. In that case, the user selects whether to include the
shipping charges in the fulfillment order.

Then, the flow is ready for


one more loop through the
items to be fulfilled.

108
Screen Flow:
Create Fulfillment Orders
8a. Build Fulfillment Order Item Inputs
The flow uses a double loop through the selected items to group
them into fulfillment groups by location.

The outer loop starts by retrieving the current item's order item data
and checking whether it's already been added to a group. If not,
then it records the item's fulfillment location and heads into the
inner loop.

109
Screen Flow:
Create Fulfillment Orders
8b. Build Fulfillment Order Item Inputs
The inner loop checks each item's assigned location to see whether it matches the current
outer loop item's location. If so, it creates a fulfillment order item input for the inner loop
item, and adds the input to a list.

110
Screen Flow:
Create Fulfillment Orders
8c. Add Delivery Charges if Selected
When the inner loop adds the first input to a
list, it checks whether the user chose to include
delivery charges. If so, it adds inputs for the
delivery charge items to the list.

And that's the end of the inner item loop.

111
Screen Flow:
Create Fulfillment Orders
8d. Create Fulfillment Group Input
When the inner loop exits, the outer loop takes any fulfillment order item inputs it
produced and adds them to a fulfillment group input. Then it adds that input to a list.

And that's the end of the outer item loop.

112
Screen Flow:
Create Fulfillment Orders
9. Create Fulfillment Order
Finally, the flow is ready to create fulfillment orders and fulfillment order items. It passes
the list of fulfillment group inputs to the Create Fulfillment Order invocable action.

The default value of a fulfillment order's Source__c is NO_ROUTING. Since this flow
doesn't set the Source__c, the fulfillment orders it creates get picked up by the Schedule
Fulfillment Order Transfer flow.

If the action succeeds, the flow continues to stage 5: the confirmation screen, and a happy
Salesforce Order Management user!

113
Schedule Fulfillment Order Transfer Flow

This flow creates interaction orders and interaction order


items for fulfillment orders that didn't come from the routing
flows.

Create
Allocated
Interaction
Fulfillment
Order &
Order Not from
Interaction
Routing Flows
Order Items

114
Flow:
Schedule Fulfillment Order Transfer
When does it run?

● Runs on fulfillment orders with the following values:


○ Status: Allocated
○ Source__c: NO_ROUTING
● Triggered by the Fulfillment Order Status Changed
event
● Processes the fulfillment order if the event shows its
Status changed from null to Allocated

The Status change indicates that the fulfillment order is


new, and the Source__c indicates that it was created by a
human user via the Create Fulfillment Orders screen flow.

115
Flow:
Schedule Fulfillment Order Transfer
1. Get Transfer Data for Fulfillment Order Items
First, the flow loops through the fulfillment order
items belonging to the fulfillment order.

For each one that isn't a delivery charge, the flow


collects the data needed to create an interaction
order item for it, including the product, quantity,
source location group, and target location. This data
comes from the fulfillment order, the fulfillment
order item, and the associated order item.

It adds the inputs to a list so it can create all the


records with one Assignment element.

116
Flow:
Schedule Fulfillment Order Transfer
2. Create Input and Check for Reship
Next, the flow creates the interaction order input
with the values from the previous step and these
defaults:
● Schedule__c = Current DateTime
● Status__c = REQUESTED
● Type__c = TRANSFER_ROUTING

These values tell the Routing Step 3: Execute Routing


flow to process the interaction order.

If the fulfillment order is for a reshipment, Type__c is


changed to CREATE_RESERVATION. That sends the
order to the Create Inventory Reservation flow.

117
Flow:
Schedule Fulfillment Order Transfer
3. Create Interaction Order and Interaction Order Items
Next, the flow creates the interaction order.

Finally, the flow creates the interaction order items for the
interaction order, using the input list it set up earlier.

118
Create Inventory Reservation Flow

This flow creates inventory reservations for items being


reshipped.

Interaction
Inventory
Order with
Reservations
Interaction
for Item
Order Items to
Reships
Be Reshipped

119
Flow:
Create Inventory Reservation Flow
When does it run?

● Runs on interaction orders containing interaction


order items to be reshipped
● Triggered when an interaction order is created or
updated with the following values:
○ Status: REQUESTED
○ Type: CREATE_RESERVATION
● Waits to process the interaction order until the
datetime stored in the interaction order's
Schedule field

120
Flow:
Create Inventory Reservation Flow
1. Get Reservation Data for Reship Items
First, the flow loops through the interaction
order items belonging to the interaction
order.

For each physical product, the flow uses the


product SKU, Quantity, and ToLocation values
to create an input record for the Create
Reservation action.

It then adds the input record to a list.

121
Flow:
Create Inventory Reservation Flow
2a. Create Inventory Reservations
Next, the flow passes the list of inputs to the Omnichannel
Inventory Service Create Reservation invocable action.

If the action call fails, and the failure limit hasn't been reached,
the interaction order is rescheduled to be processed again in
one hour.

If the failure limit is reached, then the flow creates a process


exception and sets the interaction order's Status__c to
ABANDONED.

This flow uses a failure limit of 4. It abandons the interaction


order if the action call fails a fifth time.

122
Flow:
Create Inventory Reservation Flow
2b. Create Inventory Reservations
If the Create Reservation action call succeeds, but returns
any errors, the flow creates a process exception, sets the
interaction order's Status__c to COMPLETED_FAIL, and then
exits.

Otherwise, it continues to its final step.

123
Flow:
Create Inventory Reservation Flow
3. Update Interaction Order Status
If the action succeeded with no errors, then this flow is done! It's created
reservations for the items being reshipped.
It finishes by setting the interaction order's Status__c to COMPLETED_SUCCEED.

124
Prep Fulfillment Order for Transfer Back Flow
This flow creates an interaction fulfillment order and
interaction fulfillment order items for a cancelled fulfillment
order. They're used to transfer the canceled items from the
reservation location back to their parent location group for
reallocation.

Prepare
Cancelled
Fulfillment
Fulfillment
Order Canceled
Order Items for
Transfer Back

125
Flow:
Prep Fulfillment Order for Transfer Back
When does it run?

● Runs on fulfillment orders when they're canceled


● Triggered by the Fulfillment Order Status Changed event

126
Flow:
Prep Fulfillment Order for Transfer Back
1. Get Canceled Fulfillment Order Information
First, the flow verifies that the fulfillment order
has a fulfill from location, and exits if it doesn't.
Otherwise, the flow gets information about the
canceled fulfillment order and its fulfillment
order items.

127
Flow:
Prep Fulfillment Order for Transfer Back
2. Check for Reshipment
Next, the flow checks whether the fulfillment
order is for a reshipment.
If it's a normal fulfillment order, then the
interaction fulfillment order will transfer its
reservations back to their original location group.
If it's for a reshipment, then the interaction
fulfillment order will release its reservations.

128
Flow:
Prep Fulfillment Order for Transfer Back
3a. Create Interaction Fulfillment Items
Now it's time to create interaction fulfillment items for each of the fulfillment
order items.

129
Flow:
Prep Fulfillment Order for Transfer Back
3b. Check for Reservation Location
The first step is to initialize a temporary interaction
fulfillment order item record and get the order item
summary data.
Then the flow verifies that the order item has a reserved at
location set. If not, it creates a process exception and exits.

130
Flow:
Prep Fulfillment Order for Transfer Back
3c. Create Interaction Fulfillment Item
Next, the flow looks at the order item's reserved at location. If it's the same location that
the fulfillment order's assigned to, rather than a location group, then it's a BOPIS item.
In that case, we don't want to transfer it anywhere else, and the flow skips it.
Otherwise, it sets the from location and the to location or location group for the
interaction fulfillment item.

131
Flow:
Prep Fulfillment Order for Transfer Back
3d. Add Interaction Fulfillment Item to List
Now that the interaction fulfillment item is ready, the flow adds it to a list and continues
looping through the fulfillment order items.

132
Flow:
Prep Fulfillment Order for Transfer Back
4. Create Interaction Fulfillment Order and Items
Finally, if there are any items to transfer, the flow creates the interaction fulfillment order
and interaction fulfillment order items. It sets the interaction fulfillment order's Status__c
to REQUESTED.
It also sets the interaction fulfillment order's Type__c. The value depends on whether the
fulfillment order was a reshipment:
● Not reshipment: TRANSFER_CANCEL
● Reshipment: TRANSFER_RELEASE

The Type__c value controls whether the


interaction fulfillment order is processed by
the Transfer Back Reservation flow or the
Release Reship Inventory Reservation flow.
133
Prep Fulfillment Order Item for Transfer Back Flow
This flow creates an interaction fulfillment order and
interaction fulfillment order item for a partially canceled
fulfillment order item. They're used to transfer the canceled
quantity from the reservation location back to its parent
location group for reallocation.

Fulfillment Prepare
Order Item Cancelled
Quantity Quantity for
Decremented Transfer Back

134
Flow:
Prep Fulfillment Order Item for Transfer Back
When does it run?

● Runs on fulfillment order items when their quantities are reduced


● Triggered by the Fulfillment Order Item Quantity Changed event
● Calculates the quantity to transfer by subtracting the event's NewQuantity value
from its OldQuantity value.

135
Flow:
Prep Fulfillment Order Item for Transfer Back
1. Get Cancelled Fulfillment Item Information
First, the flow gets the rest of the
information it needs about the fulfillment
order item being cancelled, including the
original location group, current reservation
location, and product SKU.
Before continuing, the flow checks the order
item's ReservedAtLocation, which is the
reservation's original location group. If it's
null, then there's no location group to
transfer the reservation back to. In that case,
the flow creates a process exception and
exits. 136
Flow:
Prep Fulfillment Order Item for Transfer Back
2. Check for BOPIS or Reship
If the cancelled fulfillment order item was intended for
in-store pickup, we can't simply reallocate it to a different
location. In that case, the flow exits.
Otherwise, the flow checks whether the fulfillment order is
a reshipment and sets the transfer type accordingly.

13
7
Flow:
Prep Fulfillment Order Item for Transfer Back
3. Create Interaction Fulfillment Records
Finally, the flow creates an interaction fulfillment order and interaction
fulfillment order item with the following values:
● InteractionFulfillmentOrder.Schedule__c: Current datetime
● InteractionFulfillmentOrderItem.Quantity__c: (Old Quantity - New
Quantity) from the event record
● InteractionFulfillmentOrderItem.ToLocationGroup__c: original
ReservedAtLocation from the order item
● Both records: Status__c: REQUESTED
● Both records: Type__c:
○ Not reshipment: TRANSFER_CANCEL
○ Reshipment: TRANSFER_RELEASE
The Type__c value controls whether the interaction fulfillment order is
processed by the Transfer Back Reservation flow or the Release Reship
Inventory Reservation flow.
13
8
Transfer Back Reservation Flow
This flow transfers reservations from a fulfillment location
back to their original location group so they can be rerouted.
It's used when a fulfillment location cancels a fulfillment
order or fulfills a partial quantity of an order item. In the
latter case, only the unfulfilled quantity is transferred.

Transfer
Interaction
Reservations
Fulfillment
Back to
Order for Cancel
Original
Created or
Location
Updated
Group

139
Flow:
Transfer Back Reservation
When does it run?

● Runs on an interaction fulfillment order with Status__c


REQUESTED and Type__c TRANSFER_CANCEL
● Triggered when an interaction fulfillment order is
created or updated
● Runs at the interaction fulfillment order's Schedule
time.

140
Flow:
Transfer Back Reservation
1. Get Item Data and Create Transfer Inputs
First, the flow gets the interaction fulfillment
order items and loops through them.
For each item, it creates an input for the
Transfer Reservation call and adds it to a list.

141
Flow:
Transfer Back Reservation
2. Transfer Inventory Reservations
The flow then passes the transfer requests to the Transfer Reservation
invocable action.
If the action call fails, and the failure limit hasn't been reached, the
interaction fulfillment order is rescheduled to be processed again in
one hour.
If the failure limit is reached, then the flow creates a process exception
and sets the interaction fulfillment order's Status__c to ABANDONED.
This flow uses a failure limit of 4. It abandons the interaction fulfillment
order if the action call fails a fifth time.

142
Flow:
Transfer Back Reservation
3. Check for Errors
If the action returns any errors, the flow creates a
process exception and sets the interaction fulfillment
order's Status to COMPLETED_FAIL.
Otherwise, we're all set, and it sets the interaction
fulfillment order's Status to COMPLETED_SUCCEED.

143
Release Reship Inventory Reservation Flow
This flow releases reservations for reshipments that the
fulfillment location cancels.
It's used when a fulfillment location cancels a reshipment
fulfillment order or fulfills a partial quantity of a reshipment
order item. In the latter case, only the unfulfilled quantity is
released.

Interaction
Fulfillment
Release
Order for Cancel
Reservations
Reship Created
or Updated

144
Flow:
Release Reship Inventory Reservation
When does it run?

● Runs on an interaction fulfillment order with Status__c


REQUESTED and Type__c TRANSFER_RELEASE
● Triggered when an interaction fulfillment order is
created or updated
● Runs at the interaction fulfillment order's Schedule
time.

145
Flow:
Release Reship Inventory Reservation
1. Get Item Data and Create Release Inputs
First, the flow gets the interaction fulfillment
order items and loops through them.
For each item, it creates an input for the
Release Reservation call and adds it to a list.

146
Flow:
Release Reship Inventory Reservation
2. Release Inventory Reservations
The flow then passes the release requests to the Release Reservation
invocable action.
If the action call fails, and the failure limit hasn't been reached, the
interaction fulfillment order is rescheduled to be processed again in
one hour.
If the failure limit is reached, then the flow creates a process exception
and sets the interaction fulfillment order's Status__c to ABANDONED.
This flow uses a failure limit of 4. It abandons the interaction fulfillment
order if the action call fails a fifth time.

147
Flow:
Release Reship Inventory Reservation
3. Check for Errors
If the action returns any errors, the flow creates a
process exception and sets the interaction fulfillment
order's Status to COMPLETED_FAIL.
Otherwise, we're all set, and it sets the interaction
fulfillment order's Status to COMPLETED_SUCCEED.

148
Thank You

You might also like