In this post, I will walk you through my experiment last week to show the weather information in a booking screen in Dynamics 365 Field Service. The business drivers behind this information could be for the planners/schedulers to see weather conditions in the specific areas where the field technicians are scheduled to work/are currently working. Take PowerApps out and this becomes another ‘data integration’ project. I did the following without writing code by embedding a Canvas PowerApp app in Dynamics 365 Field Service:
Following are the steps:
- Go to PowerApps Make Portal
- Click on Data
- Select Bookable Resource Booking entity
- Open Main form
- Click on Switch to Classic. This will open a legacy form builder
- You’re going to show weather per latitude/longitude information on the Booking record. Bring the latitude field to the General tab above Notes
- Select Latitude and click on Properties. Go to the last tab ‘Controls’, select ‘Canvas app’, and then click on Customize. What you’re doing here is to tell the system that Latitude information is not going to be shown in a boring textbox, instead, a Canvas app (which you are yet to configure) will show this information
- Clicking Customize in the previous step will spin-off a canvas app creation process and you’ll be led (in a couple of minutes) to a new Canvas app builder
- Click on the tree view on the left, get rid of any existing controls and add 5 labels. We’ll use them to show the current temperature, UV index, humidity, weather conditions and to display weather unit (Centigrade/Fahrenheit).
- The key thing to understand here is a control called ‘ModelDrivenFormIntegration’. This is your window into the Booking record in Dynamics 365 Field Service which can be used to retrieve the value of any field (not just the ‘latitude’ field)
- To get the weather information, go to Data Sources, find and add MSN Weather
- We will use MSNWeather.CurrentWeather to get the weather details. The function uses latitude and longitude to be passed and we use ‘metric’ as the unit. Following ‘Text’ value is get the current weather:
Text([@ModelDrivenFormIntegration].Item.Latitude) & "," & Text([@ModelDrivenFormIntegration].Item.Longitude),
) & "°"
- Accordingly set the values of other fields to get UV Index, Humidity and Weather Conditions
- Save the app and publish
- Go back to Bookings form editor in Dynamics 365, save and publish the form
Feel free to download the app and share your feedback 😊.