Hi everyone,
I'm trying to generate a Word document using Power Automate that includes nested repeaters. My data structure includes parent items with multiple child items, and I need to display this in a Word template. Here is an example of my data:
[
{
"Serial Number": "1",
"Title": "1",
"Subtopics": [
{
"KategorieSubtopics": "1",
"TitleSubtopics": "Title 1",
"SerialNumberSubtopics": "Serial 1"
}
]
},
{
"Serial Number": "2",
"Title": "2",
"Subtopics": [
{
"KategorieSubtopics": "2",
"TitleSubtopics": "Title 2",
"SerialNumberSubtopics": "Serial 2"
}
]
}
]
I can display the parent data (Serial Number and Title) in the Word template, but I'm struggling to display the nested child data (KategorieSubtopics, TitleSubtopics, SerialNumberSubtopics). I've tried using nested tables, but the data doesn't seem to populate correctly.
Has anyone successfully implemented nested repeaters in a Word template using Power Automate? Any advice or examples would be greatly appreciated!
Thanks in advance!
Thanks @AlexEncodian for suggetion.
I ended up using just one repeating table, creating one JSON array for parent and child both and removing the serial number from the child items so it looks like nested in the word. It worked in my case since I have the similar structure for parent and child data.
@v-mengmli-msft the data to be populated has a nested structure. You don't need to put the populate word into an apply to each for this.
@ppsao I do not think nested arrays are supported by the native Word connector / populate word action. Someone else might be able to correct me.
Encodian's Populate Word Document action supports this use case and many others. You simply put a repeating sections within a repeating section using the Encodian Template Syntax (does not use content controls - just plain typed text)
The repeating content syntax article has a sub section about nested arrays
For example:
I corrected the JSON like this:
{"items":
[
{
"SerialNumber": "1",
"Title": "1",
"Subtopics": [
{
"KategorieSubtopics": "1",
"TitleSubtopics": "Title 1",
"SerialNumberSubtopics": "Serial 1"
}
]
},
{
"SerialNumber": "2",
"Title": "2",
"Subtopics": [
{
"KategorieSubtopics": "2",
"TitleSubtopics": "Title 2",
"SerialNumberSubtopics": "Serial 2"
}
]
}
]
}
I set up the template like this:
And I got this outcome:
You can control the formatting and spacing in the template. You can see the output just reflects the tabs / line spaces i used in the template.
Hi @v-mengmli-msft ,
Sure, here are the screenshots.
Word template is not inside Apply to each loop. I just have one template stored in document library.
This is the template with nested repeater - Parent and child. Parent repeater has 1 test box and Child repeater has 2 text boxes.
When I populate this template in power automate, Ideally I should get two repeating section with 2 "Add new Item" buttons, one for parent and one for child. But I ma getting only one button. It should allow me to add multiple child items under one parent.
I tried to prepare Array of objects also in the required format and assign that variable in this section, but I am still not able to get data in second repeating section
Hi @ppsao ,
The provided expression is to get the second level of data. I am just assuming that the Populate Word Template is inside Apply to each because I don't know your flow. Maybe you can provide some screenshots, it will help us understand the problem and provide the solution.😀
Best regards,
Rimmon
My problem is - the second level of data i not being populated in the output word file, even with the hard coded values. Withe one level of repeater control, I am able to display data.
Hi @ppsao ,
If you are using Apply to each to populate value of array to word template, you can try this in KategorieSubtopics field.
items('Apply_to_each')?['Subtopics/KategorieSubtopics']
Same logic for TitleSubtopics field and SerialNumberSubtopics field.
Best regards,
Rimmon