Looking for PowerObjects? Don’t worry, you’re in the right place! We’ve been part of HCL for several years, and we’ve now taken the final step in our acquisition journey: moving our website to the HCL domain. Nothing else is changing – we are still fanatically focused on Microsoft Business Applications!

PowerObjects Blog 

for Microsoft Business Applications

| | |

Route Optimization With Flow and PowerApps: Power Platform App for Delivery Fulfillment

Post Author: Joe D365 |

Scenario: Your organization receives orders and then delivers those orders to customers. The drivers in your organization show up for work at a warehouse, pick a truck that's already been loaded with packages, and heads out for the deliveries. But… once the drivers are in the trucks, how do they know which package to deliver first? And how can they deliver all packages efficiently – spending the least amount of time driving?

The answer: route optimization. When it comes to delivering packages efficiently, route optimization is crucial – and it can be accomplished by implementing a solution built with Power Apps and Flow! Let us show you how…

Before we begin, let's cover a few parameters:

1. The app we're building connects to Dynamics 365 for Customer Engagement in order to:

  • House delivery-related information
  • Send and receive addresses for delivery

2. Via Flow, the app uses Google's API to perform the route optimization action for drivers.

Now, let's get started!

App Interface

Screen 1 - "Available Trucks"

Drivers picks from a list of available trucks. These Truck records are created in Dynamics 365 and displayed in Power Apps using the standard Dynamics 365 connector.

route optimization

Screen 2: "Deliveries" (a unique list for each truck)

This screen shows the deliveries contained in the Truck selected on Screen 1. As you will see, each Delivery has an associated Address. Clicking Optimize Route on this screen sends the address information to an Azure function, and within a matter of seconds displays an optimized route in Google Maps. More on that later.

route optimization

Fun Side Note: Clicking Optimize Route brings up a screen with a fun GIF. As the route optimization is being performed, the screen shows a navigation marker that's being chomped on. ?

route optimization

Screen 3: Delivery Details

Open one of the Delivery records in the previous screen to view its details. Click Navigate to open the phone's maps app with this delivery's address.

route optimization

Flow Details

Below is the Flow that is triggered upon clicking Optimize Route.

1. Power Apps general information.

route optimization

2. The Initialize variable step defines the start and end location, which we have defaulted to as Minneapolis, MN.

route optimization

3. Get the Address information from the Delivery records for the specified Truck.

route optimization

4. Define a variable "value" that contains the start point, end point, and addresses.

route optimization

5. Send the information contained in Step 4 to an Azure function. This Azure function sends the information to the Google Maps Directions API, which sends it back to the Azure function in an optimized fashion.

Note: The Directions API is very nominally priced, starting at $.005 per call ($5 for 1,000 calls).

route optimization

6. The Azure function sends the optimized route back to Power Apps in a URL format. This URL is then opened in the device's native maps application. In our case, here's what Google Maps displays:

route optimization

And there you have it! With Power Apps and Flow, you can build your own fully-functioning delivery app that incorporates route optimization.


This app highlights two very powerful features of PowerApps:

1. If you have a need for a mobile app that has a very specific use case – however complex it may seem, Power Platform is definitely a viable platform for it because of its ability to work with practically any application in existence. And as you can see, a fairly complex app can be built quite easily using Power Platform.

2. Cost! Power Apps and Flow are most likely included in your Dynamics 365 or Office 365 plan. You will be not be paying any additional licensing fees for a single app.

Visit our Power Apps and Flow webpages to learn more. Happy Flow'ing!

By Joe D365
Joe D365 is a Microsoft Dynamics 365 superhero who runs on pure Dynamics adrenaline. As the face of PowerObjects, Joe D365’s mission is to reveal innovative ways to use Dynamics 365 and bring the application to more businesses and organizations around the world.

PowerObjects Recommends