Saturday, March 2, 2019

Dynamics CRM Field Service Journey 4 – Automate IoT Alerts to Work Orders using Microsoft Flow

Connected field service is come in handy if your company use IoT devices to monitor larger machineries or factories etc. Using connected field service so many things you can achieve.

For example: If company selling cooling system then they can integrate IoT device within it to monitor the cooling measurements and alert if cooling system failures. Once system install in customers facility it will become customer asset and selling company need to do regular maintenance and also repair the cooling system if it has some failures. In old days human interaction is highly involving with such failure checks. There are technicians who visit cooling system facilities daily or hourly and monitor status and report it. In IoT era those daily routine checks did automatically without human interactions. Modern IoT devices are more capable than their early stages. There are some IoT devices can perform some specific tasks rather than working as reporter. Dynamic 365 Field Service use that capabilities to maintain customer assets remotely. Using Connected Field Service users can monitor output from the IoT devices and perform some basic checks of some actions like reset cooler fan speed etc. In Dynamic CRM it records those IoT readings in IoT alerts. There is no inbuilt IoT alert to work order conversion process in connected field service. We can use Microsoft Flow to fulfil that requirement.


Steps to create Microsoft Flow to automate IoT alert to work order
In following scenario we use IoT device located in cooling system and it communicating with CRM via connected field service. Company need to check content of the IoT alert and make decision based on the temperature it reports and create work order

Step 1: Choose record creation trigger from MS Flow and configure it to trigger when IoT Alert record create









Step 2: Use data operation called “Parse JSON” to parse Alert Data in the IoT alert record. After parsing the data you can use properties of the data to check the conditions. In this case I use reading value and if that value exceed 90 I will create work order automatically.
Parse JSON provide capability to generate schema using existing data. You can copy paste existing Alert data from CRM and generate schema from it. 


You can search json in action search box and it will show the Parse JSON action in Actions pane.



Extract JSON from IoT Alert record




Used that JSON to generate schema


Note: In this case it generate schema for Reading and Threshold properties as integer but it is not integer. I have to change them to number instead of integer

Step 3: Use condition to check reading value and retrieve relevant data to create work order
Check reading value is exceed 90 or not.




Step 4: Generate Work Order

To generate work order you need following mandatory information. Based on your requirement you can fill more fields in work order record.
We filled following fields


  • Service Account – Extract from Customer Asset record
  • Work Order Type – Extract from CRM
  • Incident Type – Extract from CRM
  • Work Order Number – Generate inside Flow
  • Price List – Extract form Work Order Type record
  • System Status – hardcode inside the flow (Open Unscheduled)

Retrieve Customer Asset Record using IoT alert

Retrieve Work Order Type record – retrieve work order type named “Install or replace” this can change based on requirement


Retrieve Incident Type record - retrieve incident type named “Unit Overheating” this can change based on requirement



Generate Work Order number – this should be unique number to the system. For demonstration we simply retrieve all work orders and count them but it will be a performance hit in live environment. You can use work orders with prefix to identify the customers and IoT alerts. However if you create work order from CRM it will auto generate number for you it is unfortunate it will not filled when you creating it via API or Flow.

There is a blog post describe how to count records and please refer that for more information


Dynamics CRM Field Service Journey 3 – Get Records Counts using List Records action in Flow


Generate work order using previously retrieved data

You can fill relevant lookup data using previously retrieved records like following example show how to fill price list from work order type. If your field is not showing in the list you can click on show more and set the field


Completed work order