Power Automate: Add Common Data Service files as attachments to Modern Approval

Why?

In my previous posts, I explained the example of Power Automate: Get Common Data Service Files related to an Entity to Power Automate: Email Common Data Service Files related to an Entity. Now we do not want to email the files, but add the files as attachment to the awesome Modern Approval of Power Automate. 📎

What?

I tried to do the exact same setup as in the above mentioned email post = instead of email the array with attachments just use the array with attachments in the Attachments property of the Start and wait for an approval action but somehow in the Modern Approval the action would fail:
“The request failed. Error code: ‘InvalidRequestContent’. Error Message: ‘The request content was invalid and could not be deserialized: ‘Could not find member ‘ContentBytes’ on object of type ‘ApprovalsConnectorAttachment’. Path ‘attachments[0].ContentBytes’, line 1, position 425.’.’.”

How?

It appears that the Modern Approval actions do not like the ContentBytes part of the array so I tried replacing it with Content:

{
  "Name": @{items('Apply_to_each_NotesOfInvoice')?['filename']},
  "Content": @{base64ToBinary(items('Apply_to_each_NotesOfInvoice')?['documentbody'])}
}

resulting in me now having two arrays in my flow:

  • varDocumentsArray for the email attachments
  • varDocumentsArrayApproval for Modern Approval attachments

I can use the second array in the Attachments property of the Start and wait for an approval action so the attachments show up in my email Inbox being part of the Modern Approval Card:

as well as in my Approval Center being part of the Modern Approval Item:

5 thoughts on “Power Automate: Add Common Data Service files as attachments to Modern Approval

  1. I was able to get the function to work, but the PDF attachment was ‘corrupt’ and would not open from the email 🙁

Leave a comment