How to Automate Service Reports for D365 Field Service | Part 1
If you’ve ever had a technician come out and fix something, you know how helpful it is to get a clear summary of the work that was done. Field service organizations face the same reality, sending a document that outlines the work performed isn’t just paperwork, it’s a way to keep customers in the loop, build trust, and avoid any confusion down the road. These service reports show exactly what was fixed, replaced, or inspected, give customers a reference for future service, and make your team look professional and reliable. It’s a simple step that can make a big difference in customer satisfaction. In this article I am going to show you how you can accomplish that by creating a Power Automate flow that populates a word document with data from Dynamics 365 Field Service! I will then configure the flow to turn the word doc into a PDF and email the document to the customer. This functionality can be used in many different scenarios, for example with quotes or orders in Dynamics 365 Sales.
However, the scenario I picked for this article is a Field Service scenario; when a work order’s system status is set to completed the the Power Automate flow will be triggered. The flow will query Dataverse for any related work order products and work order services that have a line status of ‘used’, as I don’t want to show any unused products or services on the document that I will be sending to the client. Keep in mind that this is just an example of the great things you can do with Power Automate. I wanted to keep this flow as short as possible so I didn’t build in some of the checks you would want, I.E does the customer that I am sending this to have an email address? What if there are no products and services used, etc. So if you want to use this in your production environment make sure you add those checks! I also didn’t store the documents on the related SharePoint document library for work orders or accounts, but this is logic that you could add. Since there is a bit of prep and there are a lot of steps in this flow, I’m breaking this article up into two parts. Part 2 will be published next week. Now let’s get started!
Create Word Document/Template
I am going to start by creating the word document where the data will be populated in. In order to make the configurations you’ll need to expose the ‘Developer’ tab in word (instructions here). There are a few things that we need to do in order to prepare the document so that we can populate the document with data from Dynamics 365/Dataverse. You can create your own word document or you can download a template by opening word, clicking on the file tab and clicking the ‘new’ button on the left hand side. I downloaded the ‘service quote’ template and edited to fit my needs. I am going to add some fields next to the ‘to’ field to hold the data from Dynamics 365/Dataverse. The fields I am going to add are:
- FullName (this is a placeholder for the full name of the responsible contact field on the work order)
- Account (this is a placeholder for the billing account on the work order)
- Address (this is a placeholder for the address of the billing account on the work order)
- Phone (this is a placeholder for the main phone number of the billing account on the work order)
- WorkOrderNumber (this is a placeholder for the work order number)
- WOTotal (this is a placeholder for the total dollar amount for this work order)
Once you typed the fields on the word document, click on the developer tab and highlight or double click or highlight on the first field (FullName). On the controls tab, click on the ‘Plain text content control’, which is the second control in the list, then click on the ‘Properties’ control and type ‘Fullname’ in the Title field, then click OK. This is the placeholder that will show up in Power Automate flow. Repeat these steps for the account, address, phone and work order number fields and any additional fields you want to add.

After the fields are added, we still need to add the placeholders for the work order products and work order services. I already have both tables on the word document as you can see above. To allow data from related tables to be added to the word document, we need to add a repeating section content control to the table in the word document. We will have to do this again from the developer tab. Select all the 3 empty cells under the Materials table on the word doc and click on the ‘repeating section content control’ from the controls section of the developers tab.

Once the control has been added click properties again and type in the name of the table (materials, services) then click ok. These names will be shown in flow later. Now we need to add the individual fields in the table, so start typing in the names of the placeholders again:
- Product Table
- ProductQTY (this is a placeholder for the quantity field of the related work order product)
- Product Name (this is a placeholder for the name field of the related work order product)
- ProdAmount (this is a placeholder for the total amount field of the related work order product)
- Services Table
- ServiceDuration (this is a placeholder for the duration to bill field of the related work order service)
- Servicename (this is a placeholder for the name field of the related work order service)
- ServiceAmount (this is a placeholder for the name field of the related work order service)
Once you typed the above fields on in the tables, click on the developer tab and highlight or double click or highlight on the first field (ProductQTY). On the controls tab, click on the ‘Plain text content control’, which is the second control in the list, then click on the ‘Properties’ control and type ‘ProductQTY’ in the ‘Title’ field, then click OK. Repeat these steps for the remaining fields. When you’re done, save the file as a word document (docx file). Just so that Power Automate can get to the doc, I am also going to store it in SharePoint. I created a folder called ‘Templates’ and that’s where I stored the document. Now that we’ve saved the word document in SharePoint we can start working on the Power Automate flow.

1- Trigger: When a row is added, modified or deleted
I will start my flow with the Dataverse connector for the current environment. The change type will be ‘Update’ as work orders are usually not created with a ‘Completed’ system status. The table name is obviously ‘Work Orders’ and in my example the scope is organization. Since I only want to do this for work orders that have a system status of ‘Completed’ I need to filter the work orders that will trigger this flow, which I did by entering the following row filter: msdyn_systemstatus eq 690970003.

2 & 3 – Get rows by ID (Billing Account & Responsible Contact)
In the next two steps I need to get the billing account and the contact who reported the work order, so I will add a next step, again using the Dataverse connector for the current environment. The table name is ‘Accounts’ and the row ID is ‘Billing Account’. You can select columns here if you don’t want flow to return all of the account columns, but this is not required. In my example I only needed the account name, address and main phone number so next to ‘select columns’ I entered: name,address1_composite,telephone1
I also renamed these steps which you can see on the screenshots below. (You can do this by clicking on ellipse on the top right side of the window and select ‘rename’.)
For the third step I want to find the ‘Reported by Contact’ (which is another lookup field on the work order form which represents the actual person that is responsible for this work order from the customer side). Click ‘add step’ and select the Dataverse connector for the current environment. The table name is ‘Contacts’ and the row id (you guessed it!) is the ‘Reported by contact’ from the flow trigger. Again I only needed a few columns (Full Name and Email Address) so I selected the ‘fullname’ and ’emailaddress1′ columns next to ‘Select columns’ but you don’t have to populate this for the flow to work.

4 – List rows (Products)
In the next step we will query Dataverse to find any related work order products that have a status of ‘Used’. We wouldn’t want to include any unused products in the document that we’re sending to the customer. Click ‘add step’ and select the Dataverse connector for the current environment. As mentioned above, the Table name is Work Order Products. The filter rows section in this step is important, because this is where we filter the data to only include the work order products related to the work order that triggered the flow and the work order products that have a line status of ‘Used’. In the ‘filter rows’ field enter: msdyn_linestatus eq 690970001 and _msdyn_workorder_value eq then search for ‘Work Order ID’ in the dynamics content window and click to add it in the ‘filter rows’ field as shown in the screenshot below.

5 – Initialize variable (Products)
When we add the work order products to the word document, these need to be added as a table. Remember we’re querying Dataverse for all work order products that are related to the triggering work order with a status of ‘used’, which means these can be multiple records. In order to store the results of that query, we first need to create an array type of variable. This will be a container that we can use later in this flow to actually store the data in. Click on ‘New Step’ and search for ‘Initialize variable’. Enter ‘products’ as the name and set the type to ‘array’. I recommend renaming the step to ‘Initialize variable products’ so that it’s easier to see which step does what.

6 – Append to array variable
In this step we will actually use the data from the container that we created in the previous step. Click ‘New Step’ and search for ‘Append to array variable’. In the name field select ‘products’, this is the variable the data will be stored in. In the ‘value’ box we will enter the names of the fields we created in the word document and the dynamic content of the data that will need to be placed in those fields. Place your cursor in the ‘Value’ field and type an opening curly bracket { then hit enter and type double quotes (“) and type the field name of the word document, type double quotes again (“) and type a comma (,) and select the related field from the dynamic values as shown in the screenshot below. These values should come from the ‘List rows products‘ step. NOTE: Once you pick the dynamic value you’ll notice that an ‘apply to each’ window will appear around the step. I would recommend to rename the ‘apply to each’ step as shown in the screenshot below. When all the fields are added in the ‘value’ field make sure you don’t forget to type the closing curly bracket at the end. (})

I hope you enjoyed part 1 of this post! Be sure to check in next week for part 2 and the entire video on how to configure this, or subscribe here to never miss another post!



Comments are Closed