The premise of this flow is that for each location of a company, when an employee gets close to an office, an email would be sent from the corporate address to the security desk with information about the employee indicating that a pass should be provided and identifying them. Here's how you can built it.
Create a Custom SharePoint list that includes the following fields
- Title - name of the location
- Security Email - the persons who will receive the email with the request for access
- Instructions - some text to include in the email about the access
- City - the location of the office. The data must match the city names in the employee's Office 365 profiles
There are two flows that make up this solution. Trigger flows (in green) are replicated for each office location, while the main flow is shared.
Location Trigger Flow
The trigger flows leverage the experimental When I enter or exit an area location trigger. When you create the flow, record the longitude and latitude of your location. Notice that each coordinate is made up of six decimal places.
Now, create a new entry in the SharePoint list. Give it a name in the Title field, the name of the City, an email for the Security Email that will receive a notification, and optional instructions. For the Longitude and Latitude, enter the first 5 decimal places and truncate the rest (don't round the numbers).
This flow will be triggered when an employee either enters or leaves the area defined by the radius in the trigger. In our case, we only want the main workflow to run when the employee enters the area (transitionType equals 1). In that case, the user principal name, latitude, and longitude are passed to the second Flow.
When the main flow is triggered, then we know which employee (by UPN) entered and the location they entered into. So, we look up the location of the in SharePoint and return the item. Remember in the first Flow that I mentioned that only the first 5 decimal places should be saved? Here's why - when you create a Number field in SharePoint, you can only specify up to five decimal places (this holds true in the Classic and Modern experience)
So, to avoid situations of rounding and missing the exact address, I am limiting the decimal places to 5. Here's how
|Multiply the float by 100000 and convert to string||43.68293856||"4368293.856"|
|Retrieve the sub-string before the period||"4368293.856"||"4368293"|
if(equals( IndexOf(outputs('Multiply_latitude_by_100,000_and_convert_to_string'),'.'),-1), outputs('Multiply_latitude_by_100,000_and_convert_to_string'), substring(outputs('Multiply_latitude_by_100,000_and_convert_to_string'),0, IndexOf(outputs('Multiply_latitude_by_100,000_and_convert_to_string'),'.')))
|Convert string to float and divide by 100000||"4368293"||4368293|
At this point, we have coordinates that should match exactly what is in SharePoint.
Next, we look up the items in the list with the same coordinates bu non-matching cities. The latter condition will ensure that an employee is not generating emails to their own security email each they come to their own office. The information in the items is used to notify the front desk security for that location.