Exercise – Create a work order template
In this exercise, you create a Word template that contains work order details to be given to technicians.
Scenario
You work at a bicycle store and are responsible for your company's Dataverse environment.
The service manager asks you to provide technicians with a list of maintenance tasks and repairs that they must complete for customers. The physical environment doesn't allow for computers or tablets to be used efficiently, so the manager wants you to print work order forms for the technicians at the beginning of the work day.
Prepare Dataverse
For this exercise, we need to create two tables:
Work Order - Header information about a work order.
Work Order Detail - Line items for the work order, or list of tasks and repairs that a technician must complete. This is a child table for the Work Order.
The objective of this module focuses on templates. To accelerate the next steps, you can download this package file containing the tables to help you proceed.
Follow these steps in a Dataverse environment where you can proceed with the import of a solution, such as a dedicated training or development environment:
Sign in to the Power Apps portal.
In the left pane, select Solutions. In the list of solutions, select Import solution.
In the Import a solution form, select Browse to find the location of the solution zip file. Select Next to proceed to the next step.
Select Import to confirm the processing of the file.
When the solution import is complete, a notification message appears in Power Apps studio, advising you that the module was imported successfully. If you're not able to import the solution, you may need different permissions; talk to your administrator.
To ensure that all customizations are applied in the environment, open the imported solution.
From the solution screen, select Publish all customizations from the command bar. Once you see the notification Publish all customizations succeeded, continue on.
Prepare data tables
Take a moment to view and prepare the data tables. Select Tables from the left pane, and then select the MS Learn Work Order table.
In the Ms Learn Word Order columns and data pane in the lower portion of the screen, ensure that the columns displayed are: Name, Customer Name, Scheduled Date, and Service Technician Name. You can do this by selecting the +[number] more button on the right side of the column header. In the Show existing column dialog, find and select these columns and deselect any others so that your data looks like the image below:
Save your column selections.
Now let's look at the Work Order Detail table. From the Objects pane on the left side of your screen, find Tables and select your MS Learning Work Order Detail table.
From your MS Learning Work Order Detail columns and data pane select the +[number] more button and select the columns: Name, Completed, Estimated Effort (Minutes), and Service Item.
Next, let's make a lookup column to link it to the Work Order table. Doing this ensures we have a relationship with the Work Order table. Select the + [New column] button on the far right of the column bar.
In the New column panel, input/select the following:
Display name:
Work OrderData type:
LookupRelated table:
MS Learn Work Order
Select Save to continue.
Add sample data to your tables
Next we need to add some data to our tables, so that we have data to produce a work order for our technicians. To add this data, navigate to each table and select Edit. In the window that appears, you can enter this data row-by-row.
Here's some sample data for your work orders (dates aren't important to match):
| Name | Customer Name | Scheduled Date | Service Technician Name |
|---|---|---|---|
| Eric Solomon Seat Adjustment | Eric Solomon | 8/11/2023 | Preston Morales |
| Henry Ross Tire Repair | Henry Ross | 8/11/2023 | Rory Nyugen |
Enter the following information for your work order details:
| Name | Completed | Estimated Effort (Minutes) | Service Item | Work Order |
|---|---|---|---|---|
| Chain Lubricant | No | 10 | Chain Lubricant | Henry Ross Tire Repair |
| Seat Adjustment | No | 20 | Seat Adjustment | Eric Solomon Seat Adjustment |
| Tire Repair | No | 15 | Tire Repair | Henry Ross Tire Repair |
If you're a little more advanced, you can download these comma-separated values (CSV) files and import them into your data:
A file that contains a list of sample work orders. You can import this directly into your table.
A file that contains a list of sample work order detail lines.
For importing help, see Import from an Excel or CSV file. If you aren't experienced with importing data, you may find it easier to manually input data for both tables.
With our sample data setup, let's get to the crux of the exercise.
Create a document template
You've created the work order and work order detail tables, and you've added records to each. Now, you can create the document template.
In the imported solution, find the MS Learn - Word Templates - Exercise 3 model-driven app and then select Play. (You will need to open the app and publish it before playing, if you haven't already published.)
Select one of your work order records and then select Download Template from the Word Templates dropdown menu.
Important
You won't see the Word Templates dropdown menu appear until you first select an item from your work orders.
In the Download Template form, leave the MS Learn Work Order default table in the Entity dropdown menu. To ensure that the list of tasks are accessible in the template, select MS Learning Work Order Detail in the 1:N Relationship list. Select Download to proceed to the next step.
Open the Word template file that you downloaded to your computer and enable editing. (Locate the file in your Downloads folder, or wherever your downloads are saved.) You'll likely need to select Enable Editing.
Select the Developer tab and open the XML Mapping Pane.
In the XML Mapping Pane, select the urn:microsoft-crm/document-template/msls_mslearnworkorder from the Custom XML Part dropdown. Then expand the fields under the msls_mslearnworkorder dropdown.
Create the header portion of the work order form by selecting the msls_scheduleddate, msls_servicetechnicianname, and msls_customername.
Remember to right select each one, and then select Insert Content Control. Insert each as plain text. Then enter to a new line on your document to insert the next item.
> [!div class="mx-imgBorder"]Add a title, formatting, and labels to the template so that technicians can identify the values. You can set your cursor outside of template fields to add headers by using your arrow keys. When complete, your template should resemble the following image:
To list the tasks for a work order, you need to add a 3-column/2-row table in the template.
Add headers to your table for "Service Item," "Estimated Effort," and "Completed?". You can add coloring/shading as desired in your table, just as you could in any Word document, but that isn't necessary.
In the first data row of that table, add the msls_serviceitem, msls_estimatedeffortsinminutes, and msls_completed fields as plain text controls. You can find these fields by expanding msls_msls_mslearningworkorderdetail_WorkOrder_ table at the bottom of the XML Part list. (Recall that you'll need to right select, select Insert Content Control, and then select plain text, as above.)
For all work order tasks to be listed in the table, select the entire table row. Then, in the XML Mapping pane, select the msls_msls_mslearningworkorderdetail_WorkOrder_ relationship, right select, and then insert a Repeating type of control.
Save the document and then upload it to Dataverse. Select a work order record and then select Upload Template from the Word Templates dropdown menu.
Select the template Word file on your local computer and then select Upload.
After the template has been uploaded, it will be available for you to use for standardized document generation. Select a work order record and then select the new template from the Personal Word Templates section of the Word Templates dropdown menu.
The document that has been generated is downloaded to your computer. Open it and confirm that it has the work order details, including the list of tasks for the technician. At this point, you can print it to have it available for the technician.
Next steps
You've now learned how to create a Word template based on a set of related Dataverse tables, including a series of records that are repeated based on the number of applicable records. Next, you learn how to create a dynamic Excel spreadsheet based on a Dataverse table.




















