0

Populating a Word Template with multiple rows from a sharepoint list

I am using the Encodian connector to Populate a word Template and I am trying to populate a table for invoices like this:



So basically my invoice creates multiple rows for each part in an invoice. I was told by Encodian help to try this:
Tables – Encodian Customer Help
 and then apply each to append the array variable:

 

I am stuck on what I put into the apply to each as a value and it wont let me name the append to array variable:

 What I normally do for just a single row in a sharepoint list is this:

But I am not sure how to populate a single word template if I have multiple quantity, cost, and Partsandlabor for multiple rows.


Any help would be appreciated!

4 comments

  • Avatar
    Jay Goodison Official comment

    Hello George,

    The JSON structure you're aiming for would be as follows:

    {
      "Customer": "Encodian",
      "tableData": [
      {
        "Labour": "a",
        "Quantity": "b",
        "Cost": "c",
        "PartNumber": "d"
      },
      {
        "Labour": "a",
        "Quantity": "b",
        "Cost": "c",
        "PartNumber": "d"
      },
      {
        "Labour": "a",
        "Quantity": "b",
        "Cost": "c",
        "PartNumber": "d"
      }
     ]
    }

    I have setup a SharePoint List as follows:

    I have configured the word template as follows: 

    Column 1: <<foreach [td in tableData]>>

    Column 2: <<[td. Labour]>>

    Column 3: £<<[td.Cost]>>

    Column 4: <<[td.PartNumber]>><</foreach>>

    And configured the flow to collate this data into the required JSON structure: 

    On execution the table is populated:

    Edited by Jay Goodison
  • 0
    Avatar
    George Stredny

    Thank you! My trigger is when an item is created in the sharepoint list. So what do I use as the value for the apply to each?

  • 0
    Avatar
    Jay Goodison

    George Stredny

    FYI - if you dont add the "apply to each" yourself and just start adding the dynamic data from the trigger to the "Append to variable" action, Power Automate will automatically insert the "apply to each" and automatically populate the "Select an Output from the previous step" field.

    However you can do this manually too:

    triggerOutputs()?['body/Item']

    Edited by Jay Goodison
  • 0
    Avatar
    George Stredny

    Great thank you Jay!

Please sign in to leave a comment.