Power Automate Approvals Attachments With Dataverse Files

Power Automate Approvals Attachments With Dataverse Files

Power Automate approval flows can include attachments from Dataverse file columns file attachments. The approver is able to open the file and review it before choosing to approve or reject it. File columns and attachments lists must be handled different ways in an approval flow. I will show you both methods and provide templates you can use when building your own flows

Table of Contents
• Introduction: The Approval Flow With Dataverse Attachments

Dataverse File Column Approval Attachments
• Create A Dataverse Record With A FileAdd Dataverse File Column To An Approval ActionRun The Approval Flow With File Column Attachments

Dataverse Notes Table Approval Attachments
• Create A Dataverse Record With Notes & AttachmentsAdd Dataverse Attachments Files To An Approval ActionRun The Approval Flow With Dataverse File Attachments




Introduction: The Approval Flow With Dataverse Attachments

The finance department uses Power Automate approval flows to approve invoices and expenses. The approval attachments can come from a Dataverse table file column or the attachments.




Dataverse File Column Approval Attachments

Create A Dataverse Record With A File

Open Power Apps and create a new table named Invoice Approvals. Add a file type column called Invoice File.



Insert the Invoice File field into the main form. Create a new record in the table and add a invoice to the field.



Add Dataverse File Column To An Approval Action

Go to Power Automate and start a new automated flow with the Dataverse – When a row is added, modified or deleted trigger. The trigger returns only a limited set of fields from the record so we must get a row by id to obtain the full details. Then we download the invoice from the file field so we can use its file content inside of the Create Approval action.



Use this code in the Attachment Name field of the Create Approval action. It will display the full file name and extension in the approval.

body('Get_a_row_by_ID')?['md_invoicefile_name']




Run The Approval Flow With File Column Attachments

That’s all it takes to build the Power Automate approval flow with a file column attachment. Save the flow and add a new file to the library to see it run.



The approval action now includes a document file from Dataverse.




Dataverse Notes Table Approval Attachments

Create A Dataverse Record With Notes & Attachments

Go to Power Apps and create a new table named Supplier Expenses. Enable attachments for the table.



Add a timeline control into the main form. Insert several new notes with an attachment into a supplier invoice record.




Add Dataverse Attachments Files To An Approval Action

Start a new Power Automate flow with a Dataverse – When a row is added, modified or deleted trigger. List all of the rows from the Dataverse Notes table with an object id value matching the flow trigger id. Then for each notes record, check if it is an attachment and compose an attachment object to include in the approval. Add a create approval action, switch the approvals input fields to entire array and reference the compose action inside of the apply to each loop.



Filter the Notes table by using this odata query in the list rows action

_objectid_value eq @{triggerOutputs()?['body/md_supplierinvoiceid']}



Compose the attachment object using this code.

{
  "name": "@{items('Apply_to_each:_Note')?['filename']}",
  "content": {
    "$content-type": "application/octet-stream",
    "$content": "@{items('Apply_to_each:_Note')?['documentbody']}"
  }
}



Include this flow expression in the attachment field of the create approval action

outputs('Compose:_Attachment')




Run The Approval Flow With Dataverse File Attachments

Save the flow and modify the record with multiple attachments to see it run.



The flow approval appears with multiple attachments from the Dataverse record.





Questions?

If you have any questions or feedback about Power Automate Approvals Attachments With Dataverse Files please leave a message in the comments section below. You can post using your email address and are not required to create an account to join the discussion.

Matthew Devaney

Subscribe
Notify of
guest

2 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Hoang
Hoang
1 month ago

Great article as always, thanks Matthew! I always have a little difficult to understand how compose action works inside an Apply to Each function, it actually composes and appends to an array at the same time. Do you know if MS has any official document explained about this behavior?

Roland
Roland
1 month ago

I’ve done something similar, except the file wasn’t used in an approval but sent for digital signing.

Because my case always had a single file, I filtered the notes attachments (list rows) by ‘isdocument = true’, sorted by date and added a row limit of 1,so only the newest note would be returned.
That saved me unnecessary calls and allowed to use first() on the array to avoid having to use a loop.