You are here:
Order Routing Rank by Average Distance Action
In Salesforce Order Management, calculate the average distance from sets of inventory locations to an order recipient, and return the sets sorted by that average distance. Use this action to compare the average shipping distances for different sets of locations that can fulfill an order.
Required Editions
| Available in: Lightning Experience |
| View supported editions. |
| This feature requires the Salesforce Order Management add-on. To purchase, contact your Salesforce account executive. |
In Flow Builder, add an Action element to your flow. Select the Order Management category, and search for Order Routing Rank By Average Distance.
Set Input Values
Use values from earlier in the flow to set the inputs.
| Input Parameter | Description |
|---|---|
| Order Routing Rank By Average Distance Input | This input is an Apex-defined variable of class ConnectApi.RankAverageDistanceInputRepresentation. The deliveryCountryCode field is the country code of the order recipient. The deliveryPostalCode field is the postal code of the order recipient. The distanceUnit field specifies whether to return average distances in miles or kilometers, respectively. The value can be mi or km. The sortResult field specifies whether to sort the location sets in ascending or descending order by average distance. The value can be ASC or DESC. The targetLocations field is a list of Apex-defined variables of class ConnectApi.TargetLocationInputRepresentation. Each of the variables represents a set of fulfillment locations that can fulfill an order together, and includes one field: locations. This field is a list of Apex-defined variables of class ConnectApi.LocationInputRepresentation, each of which represents one location in the list and contains these fields:
|
Store Output Values
| Output Parameter | Description |
|---|---|
| Order Routing Rank By Average Distance Output | This output is an Apex-defined variable of class ConnectApi.RankAverageDistanceOutputRepresentation, which contains the list of fulfillment location sets, sorted by average distance to the order recipient. The distanceUnit field is the specified unit of distance. It can be miles or kilometers. The results field is a list of Apex-defined variables of class ConnectApi.AverageDistanceResultOutputRepresentation, each of which includes one field: distanceCalculation. It’s an Apex-defined variable of class ConnectApi.DistanceCalculationOutputRepresentation, which includes these fields:
|
Usage
To set up the Order Routing Rank By Average Distance Input:
- Use Assignment elements to set the countryCode, locationIdentifier, and postalCode field values on one or more ConnectApi.LocationInputRepresentation variables to represent the locations in a set.
- Use an Assignment element to add the ConnectApi.LocationInputRepresentation variables to the locations field on a ConnectApi.TargetLocationInputRepresentation variable.
- Repeat the previous two steps for each set of fulfillment locations.
- Use an Assignment element to add the ConnectApi.TargetLocationInputRepresentation variables to the targetLocations field on a ConnectApi.RankAverageDistanceInputRepresentation variable.
- Use Assignment elements to set the deliveryCountryCode, deliveryPostalCode, distanceUnit, and sortResult field values on the ConnectApi.RankAverageDistanceInputRepresentation variable.
- Use the ConnectApi.RankAverageDistanceInputRepresentation variable in the action input.

