web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Nested repeating table...
Power Automate
Unanswered

Nested repeating tables in word template

(2) ShareShare
ReportReport
Posted on by

Good afternoon all,

 

I am looking for a way to present an array of arrays in a printable, human readable way. 

For example, I have a "Get Items" action which returns multiple results, and for each of those results, a second "Get Items" action runs which also returns multiple results. What I would like is to repeat a table of defined structure, 1-n times.

 

I am comfortable with Word Templates and repeating sections, but this limits me to a single table with 1-n rows. This is slightly different to my current needs.

 

The array of arrays is similar to the below in structure, with the number of "Thing's" being variable;

 

 

 

 

 

[
 {
 "Thing Name": "Thing 1",
 "Thing Contents": [
 {
 "Property 1": "123",
 "Property 2": "labore et dolore",
 "Property 3": "magna aliqua."
 },
 {
 "Property 1": "456",
 "Property 2": "Ut enim ad",
 "Property 3": "minim veniam,"
 },
 {
 "Property 1": "789",
 "Property 2": "quis nostrud exercitation",
 "Property 3": "ullamco laboris nisi"
 }
 ]
 },
 {
 "Thing Name": "Thing 2",
 "Thing Contents": [
 {
 "Property 1": "ABC",
 "Property 2": "Lorem ipsum",
 "Property 3": "dolor sit amet"
 },
 {
 "Property 1": "DEF",
 "Property 2": "consectetur adipiscing",
 "Property 3": "elit, sed do"
 },
 {
 "Property 1": "GHI",
 "Property 2": "eiusmod tempor",
 "Property 3": "incididunt ut"
 }
 ]
 },
 {
 "Thing Name": "Thing 3",
 "Thing Contents": [
 {
 "Property 1": "A1",
 "Property 2": "ut aliquip ex ea",
 "Property 3": "commodo consequat"
 },
 {
 "Property 1": "B2",
 "Property 2": "Duis aute irure",
 "Property 3": "dolor in reprehenderit"
 },
 {
 "Property 1": "C3",
 "Property 2": "in voluptate velit",
 "Property 3": "esse cillum dolore eu"
 }
 ]
 }
]

 

 

 

edit: Correction to structure, thankyou @eliotcole 

 

 

This information needs to be presented in a human readable format, such as the two examples below;

----------------------------------------------

Merged table,

 

Thing 1

Property 1

Property 2

Property 3

123

labore et dolore

magna aliqua.

456

Ut enim ad

minim veniam,

899

quis nostrud exercitation

ullamco laboris nisi

Thing 2

Property 1

Property 2

Property 3

ABC

Lorem ipsum

dolor sit amet

DEF

consectetur adipiscing

elit, sed do

GHI

eiusmod tempor

incididunt ut

Thing 3

Property 1

Property 2

Property 3

ABC

ut aliquip ex ea

commodo consequat

DEF

Duis aute irure

dolor in reprehenderit

GHI

in voluptate velit

esse cillum dolore eu

------------ OR ---------------------

Discrete table repeated 1-n times.

 

Thing 1

Property 1

Property 2

Property 3

123

labore et dolore

magna aliqua.

456

Ut enim ad

minim veniam,

899

quis nostrud exercitation

ullamco laboris nisi

 

Thing 2

Property 1

Property 2

Property 3

ABC

Lorem ipsum

dolor sit amet

DEF

consectetur adipiscing

elit, sed do

GHI

eiusmod tempor

incididunt ut

 

Thing 3

Property 1

Property 2

Property 3

ABC

ut aliquip ex ea

commodo consequat

DEF

Duis aute irure

dolor in reprehenderit

GHI

in voluptate velit

esse cillum dolore eu


-----------------------------------------

The only solutions I can currently see are;

------------------------------------------

Limit to a 1d array and output a table such as,

 

Thing 1 / Item 1 / Property 1

123

Thing 1 / Item 1 / Property 2

labore et dolore

Thing 1 / Item 1 / Property 3

magna aliqua.

Thing 1 / Item 2 / Property 1

456

Thing 1 / Item 2 / Property 2

Ut enim ad

Thing 1 / Item 2 / Property 3

minim veniam,

and so on...

This looks awful, and does not meet the requirements.

--------------OR------------------------

Create a document per array item (single page document, each containing a discrete table), and merge the pages to a single document in another action. 

 

Page 1.

Thing 1

Property 1

Property 2

Property 3

123

labore et dolore

magna aliqua.

456

Ut enim ad

minim veniam,

899

quis nostrud exercitation

ullamco laboris nisi

 

Page 2.

Thing 2

Property 1

Property 2

Property 3

ABC

Lorem ipsum

dolor sit amet

DEF

consectetur adipiscing

elit, sed do

GHI

eiusmod tempor

incididunt ut

 

Page 3.

Thing 3

Property 1

Property 2

Property 3

ABC

ut aliquip ex ea

commodo consequat

DEF

Duis aute irure

dolor in reprehenderit

GHI

in voluptate velit

esse cillum dolore eu

 

This will leave huge amounts of blank space on each page, and is not a good solution to the problem.

---------------------------------------------------

 

I have tried nesting repeating sections in the word template, however the connector only recognizes the first control.

Any suggestions would be greatly appreciated. Thanks in advance.

 

Thankyou to @eliotcole for suggestions.

Screen shots of flow below for reference.

Spoiler (Highlight to read)
Tjeremiah_2-1653392186175.png

 

Tjeremiah_3-1653392215872.png

Tjeremiah_1-1653392134882.png

 

 

   

 

Categories:
I have the same question (0)
  • eliotcole Profile Picture
    4,363 Moderator on at

    Hi, @Tjeremiah , hope you don't mind, but I've a couple of hopefully easy requests to assist whomever helps you, here. If at all possible, could you please:

    1. Edit your question with screenshots of your flow (obfuscated where necessary).
    2. Just confirm that JSON (more below)
    3. List or show any errors that the flow throws at you

     

    Looking at that JSON, it doesn't appear to be nested arrays, more just extra objects within each array item. I've put the rest of this in a 'spoiler' to make it easier on the eyes in terms of the thread, however ... basically if you could confirm if that's the extent of the arrays on hand here, it does only look like one level of array right now.

    Spoiler (Highlight to read)

    I've taken the liberty of sticking the square brackets on what you showed above, and plopping it in a Javascript code block:

    [
    	{
    		"Thing Name": "Thing 1",
    		"Thing Contents": {
    			"Property 1": "123",
    			"Property 2": "456",
    			"Property 3": "789"
    		}
    	},
    	{
    		"Thing Name": "Thing 2",
    		"Thing Contents": {
    			"Property 1": "ABC",
    			"Property 2": "DEF",
    			"Property 3": "GHI"
    		}
    	},
    	{
    		"Thing Name": "Thing 3",
    		"Thing Contents": {
    			"Property 1": "A1",
    			"Property 2": "B2",
    			"Property 3": "C3"
    		}
    	}
    ]

    Was that what you meant? Or had you constructed the JSON just slightly off?

     

    Arrays within that might look more like this:

    [
    	{
    		"Thing Name": "Thing 1",
    		"Thing Contents": [
    			{
    				"Item": 1,
    				"Property": "123"
    			},
    			{
    				"Item": 2,
    				"Property": "456"
    			},
    			{
    				"Item": 3,
    				"Property": "789"
    			}
    		]
    	},
    	{
    		"Thing Name": "Thing 2",
    		"Thing Contents": [
    			{
    				"Item": 1,
    				"Property": "ABC"
    			},
    			{
    				"Item": 2,
    				"Property": "DEF"
    			},
    			{
    				"Item": 3,
    				"Property": "GHI"
    			}
    		]
    	}
    ]

    Or this:

    [
    	{
    		"Thing Name": "Thing 1",
    		"Thing Contents": [
    			"123",
    			"456",
    			"789"
    		]
    	},
    	{
    		"Thing Name": "Thing 2",
    		"Thing Contents": [
    			"ABC",
    			"DEF",
    			"GHI"
    		]
    	}
    ]

     

    I've taken the liberty of sticking the square brackets on what you showed above, and plopping it in a Javascript code block: [ { "Thing Name": "Thing 1", "Thing Contents": { "Property 1": "123", "Property 2": "456", "Property 3": "789" } }, { "Thing Name": "Thing 2", "Thing Contents": { "Property 1": "ABC", "Property 2": "DEF", "Property 3": "GHI" } }, { "Thing Name": "Thing 3", "Thing Contents": { "Property 1": "A1", "Property 2": "B2", "Property 3": "C3" } } ] Was that what you meant? Or had you constructed the JSON just slightly off?   Arrays within that might look more like this: [ { "Thing Name": "Thing 1", "Thing Contents": [ { "Item": 1, "Property": "123" }, { "Item": 2, "Property": "456" }, { "Item": 3, "Property": "789" } ] }, { "Thing Name": "Thing 2", "Thing Contents": [ { "Item": 1, "Property": "ABC" }, { "Item": 2, "Property": "DEF" }, { "Item": 3, "Property": "GHI" } ] } ] Or this: [ { "Thing Name": "Thing 1", "Thing Contents": [ "123", "456", "789" ] }, { "Thing Name": "Thing 2", "Thing Contents": [ "ABC", "DEF", "GHI" ] } ]  

    Is it actually either of the examples that I pushed out for you, there?

     

    Also, a quick edit with a potential work around:

    HTML Table

    Have you tried using the HTML table function?

  • Community Power Platform Member Profile Picture
    on at

    Thanks for the advice!

     

    Yes, I have used HTML tables, where I am embedding the information into the body of an email. My understanding is that the word connector does not have the ability to parse HTML code, example HERE . If I could do so, it would be a possible solution, as I could find ways to manipulate the HTML structure within power automate.

    I have also toyed with generating XML code within Power Automate and using that as the content of creating a file. From memory this was a laborious process though, and vulnerable to bugs. errors from the developer side.

     

    The intention is to generate a printable document, and printing an email comes with the lack of control on formatting etc. that you get with a Word document or PDF. It also makes it harder for me to control with normal SharePoint document management practices.

  • eliotcole Profile Picture
    4,363 Moderator on at

    I absolutely understand your concern there.

     

    You could try to leverage the excel API to beautify the new file, then use this (potentially not working!) Graph API call to convert the Excel to a PDF.

     

    However that might be a bit painful.

     

    Anyway, I'm working on a solution which will present your arrays as three separate arrays, that part isn't an issue. That can then be made in to your second preferential example, which looks better to me.

     

    What is an issue is how you even get the template thing to make any tables. 😅 Ah ... I see, we're talking Dynamics 365 templates that I don't have a subscription for. 🤕

  • Community Power Platform Member Profile Picture
    on at

     

    In my experience with the Word Template  action, once you wrap your head around the tagging process its very simple.

     

    I always name my tags to match the key in a key:object pair (I don't know if that is strictly necessary)

     

    Tjeremiah_0-1653394434650.pngTjeremiah_1-1653394534813.png

    I then switch to array inputs, and use an array variable to populate the repeating table.

    Tjeremiah_3-1653394783327.png

     

    The solution I 'want' to my problem above is to nest repeating sections, something like

    Tjeremiah_4-1653395035657.png

     

    Ok, I tried this before and did not see the nested table at all. I must have done something different in building the demonstration here.

    Ill work on this and see if I can get it to work after all!

    Tjeremiah_5-1653395166729.png

     

     

  • Community Power Platform Member Profile Picture
    on at

    @eliotcole wrote:

    I absolutely understand your concern there.

     

    You could try to leverage the excel API to beautify the new file, then use this (potentially not working!) Graph API call to convert the Excel to a PDF.

     

    However that might be a bit painful.

     

    Anyway, I'm working on a solution which will present your arrays as three separate arrays, that part isn't an issue. That can then be made in to your second preferential example, which looks better to me.

     

    What is an issue is how you even get the template thing to make any tables. 😅 Ah ... I see, we're talking Dynamics 365 templates that I don't have a subscription for. 🤕


    Sorry, yes its the "Premium" word connector. 🙄

     

    Also, on breaking the single array to 3 separate arrays, if I were to go down this path I would need to do so in a dynamic way, as it will not always be 3, it may be 1 or 100 or anything in-between.

  • eliotcole Profile Picture
    4,363 Moderator on at

    Cool, cool ... just quickly ... is there an 'ideal' way that your data would be set in before you push it into the Word Template?

     

    Like, I'm imagining this shouldn't need to be done in Apply to each runs once you have the data. Look at that button on the right on the Table_Repeat / Table_Repeat nest box.

     

    So, what I'd suggest you do, is fill that in manually, how it would work if you had to do that each time ... then click that button, and show me here what it looks like.

     

    Because I 100% believe that I can build that exact input for you without using loops. (select and possible xpath stuff are amazing here)

  • Community Power Platform Member Profile Picture
    on at

    I absolutely will do. It's 11pm in Victoria, Australia so will have to be a tomorrow job!

     

    Thanks for all you input so far!!

  • eliotcole Profile Picture
    4,363 Moderator on at

    Oh, yeah, like I say elsewhere, we're doing this a much more data agnostic way.

    I can make it so that it builds the perfect structure each time.

    Sleep well! 👍


    @Tjeremiah wrote:

    @eliotcole wrote:

    I absolutely understand your concern there.

     

    You could try to leverage the excel API to beautify the new file, then use this (potentially not working!) Graph API call to convert the Excel to a PDF.

     

    However that might be a bit painful.

     

    Anyway, I'm working on a solution which will present your arrays as three separate arrays, that part isn't an issue. That can then be made in to your second preferential example, which looks better to me.

     

    What is an issue is how you even get the template thing to make any tables. 😅 Ah ... I see, we're talking Dynamics 365 templates that I don't have a subscription for. 🤕


    Sorry, yes its the "Premium" word connector. 🙄

     

    Also, on breaking the single array to 3 separate arrays, if I were to go down this path I would need to do so in a dynamic way, as it will not always be 3, it may be 1 or 100 or anything in-between.


     

  • Community Power Platform Member Profile Picture
    on at

    So I have done some more testing on this, and the inner repeated table is not getting populated.

    The input array looks like this,

    [
     {
     "Tag 1": "Value 1",
     "Tag 2": "Value 2",
     "Tag 3": [
     {
     "nest_1": "ABC",
     "nest_2": "DEF",
     "nest_3": "GHI"
     },
     {
     "nest_1": "JKL",
     "nest_2": "MNO",
     "nest_3": "PQR"
     }
     ]
     },
     {
     "Tag 1": "Value 4",
     "Tag 2": "Value 5",
     "Tag 3": [
     {
     "nest_1": "123",
     "nest_2": "456",
     "nest_3": "789"
     },
     {
     "nest_1": "987",
     "nest_2": "654",
     "nest_3": "321"
     }
     ]
     }
    ]

    The action accepted the inputs, and generated the document, but the output did not contain the nested array at all,

    Tjeremiah_0-1653440051366.png

    Looking at the manual input,

    Tjeremiah_1-1653440117980.png

    I would expect to see a nested input if this were possible, but I do not.

    Manually adding an item results in this,

    Tjeremiah_2-1653440182013.png

    Where if the nesting was recognized, I would expect to see something like this (excuse ms paint editing),

    Tjeremiah_3-1653440649791.png

    At this point I don't think it is an input structure issue, but a limitation of the word template action/ Word connector.

     

    I will pursue the XML and graph API paths to get the output I want. 

     

  • eliotcole Profile Picture
    4,363 Moderator on at

    Just type some example details in those fields on the Populate a word template action, and click that tiny 't' icon, that's what I'd like to see how it fills that up. 🙂

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard