Loading
Salesforce now sends email only from verified domains. Read More
Automate Your Business Processes
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Order Routing Rank by Average Distance Action

          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:

          • countryCode — Country code of the location.
          • locationIdentifier — ID of the location.
          • postalCode — Postal code of the location.

          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:

          • averageDistance — Average distance from the locations to the order recipient.
          • locations — A list of Apex-defined variables of class ConnectApi.LocationOutputRepresentation, each of which represents a location in the set and includes two fields:
            • distance — Distance from the location to the order recipient.
            • locationIdentifier — ID of the location.
          • rank — This result’s rank among all results by average distance to the order recipient.

          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.
           
          Loading
          Salesforce Help | Article