Geocode a Custom Entity with Microsoft Flow

One of my favorite features with URS is the ability to search for Resources based on their location and even get estimated travel time calculated into the result view on the schedule board. You can view your Resources and your Resource Requirements in a map view and even see real time traffic. To be able to use this feature you need to have Longitude and Latitude on your Resource Requirement and in an extent on your custom entity. This article will take you through the steps on how to geocode a custom entity using Microsoft Flow.

So if you were to use URS with Field Service you would see that there is a Geo Code option in the ribbon menu on the Work Order and Account entities. I want to create a similar feature on my custom entity so I can manually geocode my record but from the Flow-button instead.

What input do I need?

So to start with I found the Connector for Bing Maps that had an action called “Get location by address” where the output was Longitude and Latitude. Perfect – exactly what I need! In docs.microsoft.com you can read that this action need five string fields that contains:

  • Address line
  • City
  • State
  • Postal code
  • Country

Note that these are optional parameters, but for anyone who has ever used a map to find a specific location we all know it is rarely enough with just one of a few of these, so I’m going to add all of these fields to my custom entity so I can the most accurate location as possible.

By looking at this actions output I can also see that the Longitude and Latitude I get as output is of the type float.

Adding attributes to my Custom Entity

I add these fields to my custom entity, I add them to the form and I lock the Longitude and Latitude since I want the Flow to populate them and not the User.

Let’s create that Flow!

I want to be able to trigger the Flow from the Flow-button in the Ribbon on my custom entity so I choose the CDS-trigger “When a record is selected”. I use the dynamic contect from the trigger as input to my action in the next step.

I use the CDS action called “Update a record” to return the values from my previous action back to the record of my custom entity.

API Key for Bing Maps

To get the Bing Maps Connector to work it will ask for an API Key. You can find an API Key by navigating to the Universal Resource Scheduling app (1), Settings (2), Administration (3), click on the Scheduling parameter record (4) and look at Map Api Key field.

The result

There we go! With a very simple flow we’ve replicated the functionality of geocoding on our custom entity. In another blog post we’ll dig deeper in how to use this in a URS scenario.

Kontakta oss med dina frågor!

Känner du dig osäker eller är du redo att komma igång? Kontakta oss så svarar vi på alla frågor eller föreslår ett uppstartsmöte där vi går igenom era behov.