cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bkeano
Level: Powered On

Problems with duplicate rows and Populate Word Template

I'm having some trouble with MS Flow, Arrays and the 'Populate a Microsoft Word Temple' step

 

On a basic level I want to produce a word document ( later I will change to PDF and email) from some order data, the requirement is 1 word document per order number where there will be multiple orders in the table

 

I've simplified the data for this example, and below is an example of the Order Information, in my case I'm getting it from an SQL table. So there are 2 orders, first with 6 lines and 2.nd with 2 lines

OrderNumber

Order Date

Customer Name

Product

Quantity

1001

14/08/2019

Joe Bloggs

Widget 1

10

1001

14/08/2019

Joe Bloggs

Widget 2

15

1001

14/08/2019

Joe Bloggs

Widget 3

15

1001

14/08/2019

Joe Bloggs

Widget 4

10

1001

14/08/2019

Joe Bloggs

Widget 5

20

1001

14/08/2019

Joe Bloggs

Widget 6

10

1002

15/08/2019

XYX Ltd

Widget 1

20

1002

15/08/2019

XYX Ltd

Widget2

10

 

So my order has multiple products lines and the no. of product lines will vary per order, so to populate my MS Flow template and to support repeating lines in my WORD template I've used the 'Initialise a Variable' step and then I've used 'append to array' step to collect the product information together by Order. So the2 fields 'Product' and 'Quantity' will repeat on my template as needed.

I used this document as a guide, that works perfect if you are just adding an array from your data source https://preview.flow.microsoft.com/en-us/blog/intermediate-flow-of-the-week-create-pdf-invoices-usin...

 

So before I add the 'Populate a Word Template' everything seems to look OK as below,  have 2 orders and you can see the 'Append to array' shows 6 lines under that first order ( and it shows the other 2 when I click next)

Flow 1.png

My next step is to populate the Word template, this is where it goes wrong

As soon as I add fields from the 'Get rows(V2)' the 'Apply to each' element is added and I will not get each Word document created for the number if lines in the order, so the first order gets created 6 times and the next order gets created 2 times

 

See below when what the flow looks like after the step to populate the Word template is added

Flow 2.png

As you will see the Word template is getting populated 6 times, once for each line, the data is correct, it is just doing x time per order, where x is the number of lines.

I can I prevent this?

I'm restricted in that I need to start with 'get Rows' so with an array, as I cannot use Get Row, as I will not know what ID I need to take ( It's all orders with a particular status)

2 REPLIES 2
Community Support Team
Community Support Team

Re: Problems with duplicate rows and Populate Word Template

Hi @bkeano ,

 

For your issue that "As soon as I add fields from the 'Get rows(V2)' the 'Apply to each' element is added and I will not get each Word document created for the number if lines in the order, so the first order gets created 6 times and the next order gets created 2 times", could you please share a screenshot of the configuration of "Populate a Microsoft Word Template" action in your flow?

What is the field that you want to add from the 'Get rows(V2)' action?

Could you please take a try to get the field value from the "Get a row" action instead of the 'Get rows(V2)' action?

 

Please share more details so we would try to provide a proper workaround for you.

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

bkeano
Level: Powered On

Re: Problems with duplicate rows and Populate Word Template

Hi @
Thanks for your reponse

Unfortunately I can't use 'Get Row' as I'm picking up records with a particular status ( so a number of orders), I can't see how I could identify the row ID? and then pick the next row ID with the same status?
Unless there is some way I can loop around 'Get Rows' with Get Row?.Or is there anopther way I can loop around the 'Get Rows' to filter and identify each order and then run the flow for each order?. Then the process from https://preview.flow.microsoft.com/en-us/blog/intermediate-flow-of-the-week-create-pdf-invoices-usin... would work for me

Below a screenshot of the word template content, as you will see there are more fields on this, I've simplified things on my example data, but principle the same. Once I add the order number as highlighted below the 'Apply to each' gets added ( as see's an array of data). 
Flow3.JPG

 

Really what I want it to do in a nut shell, is look at the order data and only populate the Word Template for each Order and take the Product and Quanity fields inot an array for repeating content type on the Word Template,  so from my sample data it should populate 2 orders, but it populates the word template for each line on the order, so populates 6 times for first order as it has 6 lines and twice for second order as it has 2 lines

 

Really appreciate any further help you can provide, let me know if you need any further deatils, I hope it should be easy to replicate with the sample data above

Helpful resources

Announcements
firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (4,154)