cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
phildrake198
Helper III
Helper III

Repeating Content Control issue with Apply to Each

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?:

 

record1.pngrecord2.pngwordtable.png

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @phildrake198 

 

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.



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

View solution in original post

11 REPLIES 11
efialttes
Super User
Super User

Hi!

Can you share an screenshot from your flow design, so we can see the input to Apply to each etc?

The more context info we hve, the fastest to get a useful answer

Thanx!



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



abm
Super User
Super User

Hi @phildrake198 

 

Please make sure you followed the below instructions:

Guide for using Repeating Section Content Control in the Word Online connector.

We're enabling repeating tables in the Word Online connector. When creating a template in Word, you need to add the Repeating Section Content Control. This is the control in the developer tab that helps us create a repeating table. Repeating Section Content Control enables users to repeat rows in a table and plain text. Here is a guide to work with the Repeating Section Content Control:

  1. To make a template with repeating text: First add a Repeating Section Content Control from the developer tab. Then add Plain Text Content Controllers within the parent repeat content controller. Any text that is outside a nested content controller would be static. While adding the nested content controllers, make sure to go to properties and add a unique title for them. For example, if the template looks like I would like to a and b Then the user can dynamically change the values of a and b.

  2. To add a repeating row to the template, simply add a table, select the full row (which you want to repeat) and select the repeat content controller from the developer tab. Now you can add nested plain text content controllers in the columns that you want to be dynamic. While adding the nested content controllers, make sure to go to properties and add a unique title for them.

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

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:

 

productvariable.png

 

applytoeachcondition.pngproductvaluearray.pngpopulatewordtemplatewithvariable.png

Hi @phildrake198 

 

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



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

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?

Hi @phildrake198 

 

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.



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

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?

Hi @phildrake198 

 

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



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

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.

krastevkrs1
Frequent Visitor

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.

@krastevkrs1  Thank you for leaving this here!  It fixed the issue I was having.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (5,077)