This blog will examine how to create and sign PDFs from Power Apps, Power Automate, and the Encodian Flowr Power Automate connector.
We will look at a simple Power App for employees to add their sickness details after a sick day. Once they have filled out the form, the details are generated in a signed PDF document stored against the record in Dataverse. This scenario shows you how to digitally sign and create PDF documents from a Power App. However, this scenario can be adapted to suit your business needs!
The solution uses 3 of Flowr’s actions:
This simple Power App was created from a Dataverse table, so it has the standard ‘app from datasource’ template.
A pop-up will appear when you submit the form, asking you to draw your signature with the pen input functionality. Once the signature is submitted, the pen input image will be patched back to the record we just submitted with the form. The submit button also triggers a Power Automate flow, starting the document creation process.
The formula used to patch the signature image:
Patch('Employee Sicknesses', LookUp('Employee Sicknesses', 'Employee Sicknesses'= Form1.LastSubmit.'Employee Sicknesses'), {Signature: PenInput1.Image});
The flow that is creating the document needs the ID of the current record (the ID of the record just submitted by the form), so we need to provide this variable when we run the flow:
CreateEmployeeSicknessReport.Run(Form1.LastSubmit.'Employee Sicknesses');
The pop-up appears and closes by changing its visibility from true to false using a variable called sigPopUpVis. The variable is set to true on the OnSelect property of the submit form icon and to false on the submit signature button. The visibility of the pop-up container is then set to sigPopUpVis.
After pressing the refresh icon, there is now a signed document uploaded:
You can double-click on the document to download the file and then open it in Adobe.
The document has been populated with all the sickness information provided in the Power App, including the drawn signature! It has also been digitally signed with valid signatures.
The Adobe Approved Trust List (AATL) is a system that empowers users globally to generate digital signatures. These signatures provide trust each time the signed document is accessed in Adobe Acrobat or Reader. AATL uses globally trusted digital signing certificates. The list includes certificate authorities (CAs) and trust service providers (TSPs) that issue these digital signing certificates and timestamp services that can be used to adhere to worldwide legal and regulatory standards, including the EU eIDAS regulation.
Encodian have recieved our certificate from GlobalSign.
Now, let’s look at the Power Automate flow that is running behind the scenes.
The flow is triggered from Power Apps, which uses the Power Apps trigger. The trigger has an input variable called employeeSicknessID, which is the ID of the form submitted last in the Power App.
Next, we use that ID to get that record from Dataverse using the ‘Get row by ID’ action and download the signature image using the ‘Download a file or an image’ action.
We need a Word template to use the Populate Word Document Flowr action. The template is stored in OneDrive, so we need to use the ‘Get file content’ action to access it later.
The Employee Sickness Dataverse table has a column called ‘Employee’. This is a look-up column to the Microsoft Entra ID table. When using values from this table in Power Automate, you can’t use ‘Get a row by ID’ or ‘List Rows’. You need to use the Office 365 connector.
We can use the ‘Get user profile (V2)’ action and use the same value as we would if we were using ‘Get a row by ID’ (the ‘Employee (Value)’ dynamic content as this is the GUID of the row we need in the Microsoft Entra ID table). We must do this to get the sick employee’s display name for the PDF document.
Now, we can use the Populate Word Document action to get the sickness details into the Word template. This is what the template looks like:
To use the action, you have to tag in the template file where you want each piece of data to go. You can also add conditional, date, text, and image formatting from the Word template. Here, we have some conditional formatting to change a boolean true/false value to a yes/no text value.
The template tags must match the input JSON keys in the Populate Word Document action.
The Employee Signature area has been left empty in the Word template. This is because the signature image will be populated by the ‘Sign PDF’ action later. You can populate images using the ‘Populate Word Document’ action; however, as we are already digitally signing the document, we will insert the signature image at that stage in the flow.
Extensive documentation explains how to use the ‘Populate Word Document‘ action and the syntax to use in your Word templates.
Once we have populated the Word document, we must convert it to PDF. We can do this using Flowr’s ‘Convert to PDF‘ action.
Once we have the PDF, we can sign it using the ‘Sign PDF‘ action.
The ‘File Content’ input here is the file content output from the ‘Convert PDF’ action.
We want to add the signature image to the document, so ‘Show Signature’ is set to yes. We can then provide the downloaded signature image from one of the earlier steps as the ‘Signature File Content’ and specify the page and coordinates of where the image should be placed.
Lastly, we need to save the signed PDF file. In this solution, the document is saved to OneDrive and against the record in Dataverse.
Once the flow has been completed and the Power App is refreshed, the signed document will be available to view and download from the app.
If blogs aren’t for you, check out Sophie’s companion video!
Search 150+ Actions to see how Flowr can save you time
Sign up for your free 30-day trial; no cards, catches, or contracts.
No job is too big or too small for our Professional Services team!
UPDATE: We’re excited to announce some significant updates to Flowr for Power Automate! As of October 2024, we’ve improved by updating action names and splitting Flowr’s central Power Automate connector into nine specialized connectors. These changes will make your workflow faster, smoother, and more efficient. The new action names are more precise and intuitive, saving you time, while the focused connectors enhance performance and flexibility. This update also helps future-proof the platform for even more powerful features. Check out our updated action names blog.
Technical Evangelist