Using Power Automate to create events based on an Inspection Response


I have been investigating the capabilities for Inspections since it first came out in Public Preview. It has amazing potential for Field Service technicians to be sure, but that was amplified for me within the latest update.

In the latest update, two major features were enabled in the product, conditional branching logic and enabling Power Automate to create events based on an Inspection response. When I read all about the update via the latest article from David Clarke on Microsoft Docs (linked here), there was a section on using Power Automate to run workflow on Inspection Responses. This was really cool, but used the deprecated Dynamics 365 connector! So, I thought to myself…this has to be able to be done with the CDS Current Environment connector. To be honest, I am not that proficient in Power Automate (somewhere in NZ my friend Elaiza Benitez is shaking her head in disgust), but I had to make this happen.

Scenario – Auto Insurance Claim Inspector

The Flow being described in this post uses a scenario when a Auto Insurance Claims Inspector using Dynamics 365 Field Service Inspections performs an inspection for a single-car accident. The Flow is triggered when an Inspection Response of this type is created. Different actions are taken by the flow when the person filing the claim is or is not the primary insured member. When the answer is “No”, a new inspection is created to be performed with the Primary Insured, when the answer is “Yes”, a Teams notification is generated to advise on the completed inspection and to process the claim.

A Look at the Data

Before I describe my journey, let’s talk a little bit on how the data is organized between the Work Order, Work Order Service Task and the actual Inspection.

Inspections/Work Order related ERD (generated using Entity Relation Diagram Creator via XRMToolbox)

As you may or may not know, an Inspection is presented within the Work Order Service Task form. This is due to a 1:N relationship between Inspection and Work Order Service Task. An inspection is linked to a service task type, via msdyn_inspectionid, however there are no visible lookup fields on the Inspection form given the user interface. The service task type is linked to the work order service task via msdyn_servicetasktypeid, which is displayed on the work order service task form. Inspection responses are linked to the work order service task via the msdyn_inspectionresponseid. So to cut to the point, there are multiple hops from the inspection response to get to the related work order that is linked to the work order service task. This has to be understood before leveraging the CDS Current Environment connector in Power Automate for this Flow.

Getting Started

To start this process, I was inspired by the aforementioned blog post by David Clarke, Program Manager on the Field Service team. His Flow was triggered by when a record is created or updated using the Dynamics 365 connector. So our first step is use a different trigger.

Creating the Flow – Step by Step

Step 1 – Define the trigger using the CDS Current Environment connector
Our Flow will fire specifically when an Inspection Response is Created. If you look back on the data diagram above, this is the critical piece to trigger our flow from as this is where the mineable data lies within the Inspection Response, not the Inspection itself.

Step 2 – Use Get Record
Next we need to get the Inspection Responses using the Get Record action. We choose Inspection Responses as the Entity Name and Inspection Response ID as the item identifier. This allows us to get the intended response for the automation.

Step 3 – Extract the JSON
As David illustrated in his post, we add an Initialize Variable action to retrieve the encoded response from ResponseJsonContent field.

Step 4 – Decode the response
Also as in David’s post, in order to get the response in a usable format, we add an Initialize Variable action to url decode and base 64 decode the response JSON.

decodeUriComponent(decodeBase64(variables(‘responseJson’)))

Step 5 – Update the Schema
We must next update the schema with the name of the question or questions that you want to run a workflow on. Note: it is CRITICAL that you appropriately name your Inspection Questions in order to easily understand your schema in this step. As you may notice, I did NOT practice what I preach intentionally to demonstrate how the information is presented by default. “Question10” is actually asking the question “Is the Claimant the Primary Insured?” the options for a response are “Yes” or “No”. This is the one question that I have used to trigger the entire Flow upon. I hope you can see why not naming the response correctly could cause some significant issues for you in actual practice.

Helpful Tip: Power Automate allows you to generate the schema using a sample, as shown below. In my case, I generated this schema with the example {“Question10″:”No”}.

Step 6 – List Records
In a deviation from the original example, we now list the Work Order Service Tasks that are active which will in later steps enable the ability to generate the new Inspection record related to the originating Work Order Service Task.

Step 7 – Compose Step

Next we write a Compose step to define the specifics of the Work Order Service Tasks so that we can leverage the output in the upcoming Get Record step for Work Order Service Tasks. For more information on the Compose step, take a look at the article on Docs, here.

Step 8 – Get Record: Work Order Service Tasks
Next we get the Work Order Service Tasks using the output from the previous Compose step to ensure we get the specific WO Service Task we need.

Step 9: Evaluate our condition
Now we evaluate our condition on which the entire Flow is based. The condition is evaluated on the value of “Question10”.

If it is equal to “No”, then we create a new Work Order Service Task with the appropriate Service Task Type commensurate with the Auto Claim Inspection.

If it is equal to “Yes”, then we create a Teams Notification to process the claim as indicated.

As an end result, we are able to make actionable results come from a simple Inspection, greatly increasing its value.

The complete solution can be found and downloaded here, Important: you will need to have the public preview of Field Service Inspections installed to use the sample Flow as built. For more information on how to install preview features for Dynamics 365 Field Service, refer to my previous blog post here. I hope it is helpful to help you understand how Power Automate can extend the capabilities of Field Service Inspections!

One thought on “Using Power Automate to create events based on an Inspection Response

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s