Amey Holden

View Original

Document generation before your eyes and on demand with Power Automate

Scenario: you have a really cool model-driven power app that you use to track work and create invoice records, you call it ‘Micro Financial Enterprises’. But generating the invoice documents to send to clients at the end of the month is far too clunky.

Not anymore!

Document generation in model-driven Power Apps is nothing new but there are lots of ways to do it, each has its pros and cons.

Option 3 Awesome: Use a model-driven app Custom Page with Power Automate document generation

  • Pros: all the pros from Option 2; customise the user experience exactly how you want; surface and connect data from anywhere; its part of your model-driven app; ability to handle errors gracefully and informatively; one click (or less) flow run experience.

  • Cons: you need to scrub up on your PowerFX skills (but future you will be grateful)

High level technical summary:

  • Word document is created and stored in OneDrive so any updates made to the document after generation are picked up in the PDF conversion

  • If you see a button, it calls a flow (using the Power Apps V2 trigger) and passes back useful variables

  • Dataverse tables used on this page are: Account, Invoice, Work Items, Email Message, Contacts, Users, Services and Invoice Periods

Take home message(s):

  • Using custom pages for document generation in model-driven apps is cool and terribly useful

  • It structures data properly in dataverse but visualises it enjoyably - without any code based magic, just Power automate and Power FX.

  • Go use custom pages to replace your clunky old document generation processes in Dynamics 365 and model-driven Power Apps and live happily ever after

PS. I have no idea how to write up about how I did this from end to end, but if there are specific things you would be interested in finding out more about please let me know!