Zum Hauptinhalt springen

Calculate distance and travel time in a flow

The flair Distance Calculation action returns the driving or direct distance in kilometres and the travel time in minutes between two locations. You can add it to your own Salesforce Flows to store or act on that distance — for example, to populate a field or branch on how far apart two addresses are.

Who can use this?

Salesforce Admins building flows in Salesforce Flow Builder. The flair managed package must be installed.

Before you begin

  • The flair managed package is installed in your org.
  • You have permission to create and activate flows in Salesforce Setup.

Add the Distance Calculation action to a flow

Add the action wherever your flow needs a distance — for example, in a record-triggered flow after the relevant addresses are set.

  1. In Setup, open Flows and open your flow, or click New Flow to create one.
  2. On the flow canvas, click the + where you want the calculation to run, then select Action.
  3. In the action search, enter Distance Calculation and select it.
  4. Enter a Label for the action. The API Name fills in from the label.
  5. Set the input values for the action (see Set the input values).
  6. Click Done. The action is added to the flow.

Set the input values

Provide the two locations as either addresses or coordinates, and choose the calculation type. Type is required.

InputWhat it does
TypeThe calculation method. Enter DRIVING for the driving distance along roads, or DIRECT for the straight-line distance. Required.
Address FromThe start location as an address.
Address ToThe end location as an address.
Latitude From, Longitude FromThe start location as coordinates.
Latitude To, Longitude ToThe end location as coordinates.
Request IDOptional identifier for the request. If you leave it empty, flair generates one.

Provide each location one way or the other: set Address From and Address To, or set the latitude and longitude pair for each end. To pull a value from the triggering record, select the field from the record variable — for example, $Record and then the address field.

Use the results

The action returns these outputs, which you can store in variables or reference in later flow elements:

OutputWhat it contains
distanceInKmThe distance between the two locations, in kilometres.
durationInMinutesThe travel time between the two locations, in minutes.
errorA message describing why the calculation failed, if it did.
  1. After the action, add the flow element that uses the result — for example, an Update Records or Assignment element.
  2. Reference the action's distanceInKm or durationInMinutes output in that element.
  3. Optional: add a Decision element that checks whether error is empty before using the result, so the flow handles failed calculations.
  4. Click Save, then click Activate to run the flow.