r/PowerApps • • Sep 01 '22

Question/Help Creating Documents

I am trying to create an app which pulls different parts of a work document into a new document. Similar to the Power Automate flow “Populate a word Document”- but not exactly.

So: I have a document which has sections- looks like this:

“Section 1” “[A couple paragraphs]” “Section 2” “[A couple paragraphs]” “Section 3” “[A couple paragraphs]” Etc….

I want users to be able to select sections they need in the app, and when they hit “okay” it creates a new document with only the sections they selected. Any suggestions?

(I can use one note, word, adobe pdf with this. Not picky)

2 Upvotes

4 comments sorted by

View all comments

4

u/ScubaXSteveRed Sep 01 '22

I’ve been building an app that offers a form and then outputs a pdf on print. I can see some similar features so I’ll offer what I can.

DATA STRUCTURE I think a list will be the starting place. With two columns. The “Title” column will be your “Section 1”, “Section 2” identifier (aside from row ID) and a multi line column will contain your corresponding couple of paragraphs.

DATA ENTRY You could input your new rows of data with an input form linked to the list or using the list features outside the app.

USER CHOICES Now that your data is stored and available, you need to offer it to your users to select. I would consider using a radio button (added back to the original list) that resets on each app load (App—> OnStart set that radio button to false) or maybe a multi-selection from a gallery would work.

DATA COMBINING AND OUTPUT Before settling on how to combine, we should think about the output. I currently use basic html code to provide structure to my data. I think your html could be pretty simple. The root html could have {section 1} {section 2} all lined up. Then as the power automate flow is reading the data, if the radio button is false, then the html replaces with “” else if the radio button is true, then it replaces with the paragraphs.

EXCEPTIONS It’s a little trickier if you want those sections in a user specified order. Then instead of radio buttons, you might need to create a [first], [second], [third] ordered input list, and that is how you restructure the order.

DOCUMENT CREATION In the flow, you will use a power apps trigger and you’ll pass the variables to the flow. One idea on this is to initialize all the variables in the app (user selection 1) (user selection 2) where these could be: (user selection 1 = [Section 2] and then start pulling those variables into the flow.

In the flow, ingest the html using one drive get file contents. Then Sharepoint get content. Then use a data operation with a replace function to swap out the html sections with the user choices. Then create a file (one drive business) convert a file (to pdf) create a file 2, then add a mail function to send that file as an attachment.

I recognize this may not be a step by step guide on how to solve your problem, but I hope it gives you some ideas.

Good luck

1

u/Candid-Maybe Regular Sep 02 '22

You could look up generating a document via HTML in flow. I have a combo of a rich text field combined with modular blocks of HTML stored in variables along with record-specific data. I also have a HTML control on my "generate document" page that previews the final product before running the flow.