cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Rory87
Frequent Visitor

Single Word Template with data on different pages

Hi,

 

I am trying to make a single document from several items from the same SharePoint list. This is based on how many assets the sites has so will not always be the same. I am able to make individual documents but cannot seem to merge them in to a single document. I have looked around but cannot find a option which allows one table per page.

 

I am trying to repeat the same layout on each page and end up with one 10 page document instead of 10 1 page documents. Any thoughts on how to achieve this?

 

Rory87_0-1622205743652.png

 

Example document - showing what each page currently looks like, this part works but only 1 page per file.

 

Rory87_0-1622208975608.png

 

Any advise on how to achieve this?

 

12 REPLIES 12
annajhaveri
Super User
Super User

@Rory87  Move the "Create file 2" action out of the Apply to each action, it should be like below screenshot 

 

annajhaveri_0-1622468187259.png

 

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

I have tried to move the create file out however it creates the below error. 

 

Flow save failed with code 'InvalidTemplate' and message 'The template validation failed: 'The inputs of template action 'Create_file' at line '1 and column '5158' is invalid. Action 'Apply_to_each' must be a parent 'foreach' scope of action 'Create_file' to be referenced by 'repeatItems' or 'items' functions.'.'

 

The file content then also only includes Current Item as it applies to each. I am not sure if there is a option to store the the individual sections in the flow and then combine.

Hi @Rory87 ,

Just give a try on the below steps.

1. Create a string variable

2. Append it inside the apply-each

3. Move the create file outside the apply-each loop

4. Use the string variable value to create the file

 

Thanks,

Murali.

 

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer. If you like my response, please give it a Thumbs Up.

 

Hi Murali,

 

It appears to be going in the correct direction this creates a file with a size of 1.2mb so it has created a file however it will not open.

 

The error now is Word found unreadable content in "File Name". do you want to recover....

 

If you say yet it states word experienced an error trying to open the file.

 

below are my changes

 

Rory87_0-1622536446520.png

 

@Rory87  in Initialize Variable action, please change the type to Object, then use Set Variable action instead of Append to string variable to assign the output of Word template to the variable.

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

Thanks,

 

This allows the file to open however it overwrites the variable each time to create a file with just the last set of records.

@Rory87  one thing i overlooked in your scenario, you have "Get File content using path"  so that means, you are getting files from SharePoint and want to merge all those files into one?

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

The Get File is collecting a picture from sharepoint that relates to the record. This part seems to work when making the 1 files per item word files.

 

The bit I cannot yet automate is getting all word files as a single file instead of 1 per file. Each item will complete a word template, I am hoping there is a way to connect all of these outputs in to a single file. I saw a connector to merge word files but this requires a set amount of files saved to sharepoint where as mine can change each time.

@Rory87 Do you have a repeating table in word file where you need to put the pictures or is it different sections of pictures across document that show up in the "Populate Word template" action? 

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

Hi Anna,

 

There is a single picture which gets added to a specific location, I have removed the picture for now as this is an extra. without the picture and get file content I still end up with the same issues.

 

Run with a create file in the apply to each I end up with multiple files, run with the append string I end up with a single file that cannot be opened and ran with the set object I end up with a single file but only the last item.

@Rory87  as you have apply to each, that is why you are getting multiple files. You can define variables in the beginning of the flow, and then assign the values to variables inside apply to each and then after apply to each outside of it, you can populate word template. 

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.
Rory87
Frequent Visitor

In the end rather than automate this as repeating tables would not work with my set up, I just ran individual files and imported as objects within the file.

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Kudoed Authors
Users online (3,537)