Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Triggers
  • Application specific solutions
    • Dataverse
    • Excel
    • Forms
    • Planner
    • Outlook
    • SharePoint
    • Teams
  • Resources
  • Get help with flow
Menu

Assign approval task with multiple (0 – n) attachments in Power Automate

Posted on November 8, 2020April 14, 2021 by Tom

“I need for the approver to be able to approve up to four files at the same time in his Power Automate approval task, is there a way to make the number of attachments optional?”


To make the approval process in Power Automate as user friendly as possible, you might want to include attachments in the task. It can be the item attachments or multiple documents from a library, but you can’t predict how many files it’ll be. And that can be a problem in the ‘Start and wait for an approval’ action. If you define more attachments than you have, the flow will end with ‘InvalidAttachmentName’ error. If you define less attachments than you have, some documents will be missing in the task.

Approval task input attachment detail

The solution is to build a dynamic array with the attachments as a variable and use it in the action.

Approval task input attachments array

Adding the attachments

First step you need to do is to initialize the array variable.

Initialize array variable

The next step is to get all the files. It can be ‘Get attachments’ action, ‘Get files’ action, or a list of files you’ll build by yourself. To keep the number of files optional you must be able to loop (‘Apply to each’) through them.

Loop through all the attachments, get their content, and append them into the variable with the ‘Append to array variable’ action. The code below shows you the format, just don’t forget to replace the <placeholders> with your dynamic content.

{
  "Name": <DisplayName>,
  "content": <AttachmentContent or FileContent>
}

Warning: make sure you don’t add any character nor white space after the <AttachmentContent or FileContent> dynamic content. Otherwise you’ll end with ‘AttachmentContentNotValidBase64String’ error.

In the example below, you’ll take all attachments from a SharePoint item and append them into the variable.

Store item attachments into array

Last step is to send the actual approval task, with our array variable as attachments.

Assign task with array of attachments

As a result, the approver will receive an approval task with all the attachments. Not only in the email, but in the task in the Power Automate application as well.

Approval task with multiple attachments

Summary

While I generally don’t recommend sending files as email attachments, I’d make an exception in the approval task. For the approval process it’s much easier if the approvers have all the information at the same place. The information needed for approval in the task, the final approval history directly in the list/library.

Unless they need to do some update in the file itself, then a link to the file locations is the only way.


Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Do you know what to do, but not how to do it?

Get The Ultimate Power Automate expressions cheat sheet and translate your thoughts into flows with ease!


NEW! Master the HTTP requests to SharePoint with a new cheat sheet!

Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Hello and welcome!

My name is Tom and I'm a business process automation consultant and Microsoft MVP living in the Czech Republic. I’ve been working with Microsoft technologies for almost 10 years, currently using mainly Power Automate, SharePoint, Teams, and the other M365 tools.

I believe that everyone can automate part of their work with the Power Automate platform. You can achieve a lot by "clicking" the flows in the designer, but you can achieve much more if you add a bit of coding knowledge. And that's what this blog is about.

To make the step from no-code Power Automate flows to low-code flows: using basic coding knowledge to build more complex yet more efficient flows to automate more of your daily tasks.

  • Use Power Automate to forward Outlook events upon registrationJanuary 29, 2023
  • Why the condition is false for the same numbers (Power Automate)January 25, 2023
  • How to forward event invitation to other calendar (Power Automate)January 22, 2023
  • Run ‘For selected item’ flow from non-default environment (Power Automate)January 18, 2023
  • Hide button in SharePoint list after Power Automate flow startedJanuary 15, 2023

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

©2023 Let's POWER Automate | Theme by SuperbThemes