Hi,
I am running into an unusual issue when using Apply To Each to capture multiple related records and populating a Word template that includes the Repeating Content Control. What's happening is my values from Apply To Each are getting "duplicated" in the table in Word. So instead of the correct related records, it's showing the first record values repeating in the table. My flow runs "successfully" so I can see where the related record values are getting captured but I can't figure out why the values are getting duplicated instead of repeating the unique values like I think it should. Here are some screenshots for clarity. Is there any way around this? Possibly a way to do this without the "Apply to Each" action?:
This was a lifesaver, thank you for the fix krastevkrs1! I wouldn't have figured out that one on my own.
@krastevkrs1 Thank you for leaving this here! It fixed the issue I was having.
I had a similar problem and ended up looking at the word template. I changed the docx extension to zip and inspected the xml files. It appears that when the malfunction happens the file settings.xml file had a line for the formsDesign class.
When I deleted the line and replaced the settings.xml all content shows correctly.
Hope this helps anyone.
Thank you! Yes, It duplicated because there was an additional "Apply to Each" at the beginning of the condition. So it was an "Apply to Each" within an Apply to Each. Once I removed that extra action, it worked.
Make sure your arrays have no duplicates. It's difficult to see without checking the runtime history and your template. I did send you an email earlier. Please check it.
Thanks
Ok that did solve the additional record values not showing up. The problem now though is both record values are being duplicated in the word doc in that table. Is yours pulling the record values from Dynamics like mine is and if so how did you get it to not duplicate? My Populate a Microsoft Word Template action is outside of that Apply to Each condition so I'm not sure why it's duplicating the values in the doc. Or is there some expression I can add that will resolve the duplicates?
I did tried this and it is working as expected.
Could you please try the following:
1. Change the array structure as following:
Product Part Number 1 to ProductPartNumber
Description 1 to Description
Quantity1 to Quantity
Rebate1 to Rebate
2. Make sure Populate word template is outside the apply each loop
3. Open the word template.
4. Remove the current table.
5. Save the template.
6. Add a new table x 4 rows
7. Add the heading
8. Press tab (this should create new row)
9. Highlight the whole row and add repeater control
10. Select properties of the repeater control and add the name as ProductDetails and set the tag as same name.
11. Next place your cursor in first cell of the second row, add a text box, select properties and set name and tag as ProductPartNumber.
12. Move the cursor to next column. Repeat the same as step 11 for Description, Quantity and Rebate.
13. Next back to flow again and remove the current word template step.
14. Add word template again and click the T sign, this will join all the columns into one. Here place your array variable.
15. Save and run the flow.
Let me know how it goes.
Yes I added titles for the controls, although I did notice that I forgot to add a title for the repeating control. So I went back and did that but it still doesn't display the data beyond that first set of values. I made sure to add my file back in and made sure the Populate a Microsoft Word Template action was updated to call the updated file. Based on what I've described, is there anything else that needs to be done here?
Did you do the following?
While adding the nested content controllers, make sure to go to properties and add a unique title for them.
Thanks
Sure. Here's some more detail that will hopefully be helpful. What I'm trying to do is have it pull values from related records in Dynamics and then put those values in a table that uses a repeating content control in Word. The challenge is, when you use "Apply to Each", you can't pull values from within that Apply to Each in the Populate a Microsoft Word Template action. So what I've done to work around this is initialize a variable outside of that Apply to Each and then use "Append to Array" within the Apply to Each to call that "initialize variable". Then, in "Populate a Microsoft Word template", I can "switch to array" on the repeating content control fields and then add the variable. The problem I'm running into is it just doesn't add second set of values even though they are returned in the results.
Here are some screenshots of the flow logic for more detail. Maybe I'm doing something wrong:
Michael E. Gernaey
497
Super User 2025 Season 1
David_MA
436
Super User 2025 Season 1
Riyaz_riz11
244
Super User 2025 Season 1