- Miguel Nepomuceno
Enable Repeating Table Header Rows for Repeating Content in Word Templates for Dynamic 365
Microsoft Word is a powerful tool in the Microsoft stack that allows users to create standardized documents in Microsoft Dynamics 365. Word Templates in Dynamics 365 has many trade-offs compared with making custom reports. With Word Templates, any user can quickly construct it, upload it into Dynamics 365, then run it across multiple records – all from a single Word template.
One of the biggest features about Word Templates is that, when running the Word Template on a record, we can display its related child records. Repeating Content Controls will auto populate with multiple rows of data.
This is useful, for example, on an Account record and generating its associated Invoice records to get a total amount owing to be billed to a customer. The benefits of this example extend the use of creating a Word Template into a single summarising invoice statement document.
For my example above, I have built a Word Template with a table containing a header row, and another row with my Repeating Content with some out-of-the-box and custom fields for the Invoice entity. This will populate with data from each child Invoice record. Now, when I run this on an Account record with a large amount of Invoices, the Repeating content will go across the next page of our Word document.
This posts a problem when reading the second page – how do I know which table header the data falls under? We can solve this by including the table headers breaking into the next page. To set this up, there’s a couple of tricky configurations to set with Repeating Contents.
First, in the Word Template, we need to enable ‘Repeat Header Rows’. Select the header row (i.e. the first row in our table). Then, in the Word ribbon, go to Layout tab. Under Data, select ‘Repeat Header Rows’.
Because of the nature of Repeating Content and its dynamic properties, Word does know that our table spans multiple pages yet until it is run in CRM and fills it up with data. Thus, simply enabling the ‘Repeat Header Rows’ will not work when generating our Word document.
We need to enable some formatting Table Properties in Word. Select the table, and right click Table Properties.
In the Row tab, ensure that the “Allow row to break across pages” option is enabled. The “Repeat as header row at the top of each page” should automatically be ticked since we enabled this for our header row earlier in our blog.
Lastly, in the Table tab, select the ‘Around’ text wrapping, and select OK.
This should ensure that Header Rows will flow across multiple pages of the Repeating Content with your Dynamics 365 Word Template.