Power Apps Bulk Approvals Using Power Automate

Recently, while working on the Power Apps Expense Claims application, we needed to create a screen that allows approvers to perform bulk approvals. Due to some restrictions on the visibility of the data source to users in Power Apps and performance issues, we included a Power Automate flow to achieve this.

In this article, I will explain how to perform bulk approvals in Power Apps using Power Automate flows.

Create Power Automate Flow For Bulk Approvals

Here, I will explain two different Power Automate flow approaches that will perform bulk approvals from the Power Apps application.

Look at the Power Apps bulk approval screen below. I select the employee expense reports. In the top section, I choose the approver, approval status, and provide a comment. Then, once I click the bulk approval button, the flow runs in the backend and updates the SharePoint list items with the provided data.

Power Automate approval workflow multiple approvers

Here is the SharePoint list named Employee Expense Claims.

bulk approvals in power apps using power automate flows

Which has the following fields and takes reference for the fields’ data types:

Column NameData Type
TitleDefault
EmployeeNamePerson
DepartmentChoice
ExpenseCategoryChoice
ExpenseAmountNumber
ExpenseDateDate & Time
ApproverCommentMulti line text
ApprovalStatusChoice
ApproverPerson

Power Automate Flow Approach 1:

Now, let’s start creating a Power Automate flow that performs bulk approvals:

  1. Create an Instant cloud flow with the Power Apps trigger named When Power Apps calls a flow (V2). Then, add the following parameters to this trigger with the data types:
    • ApproverComment = Text
    • ApproverClaims = Email
    • ID = Number
    • Status = Text
power automate flow bulk update
  1. Then add the SharePoint Update item action below to the trigger. Provide the data below for the parameters:
    • Site Address =Provide SharePoint site address.
    • List Name = Provide list name.
    • Id =Choose from the trigger.
    • ApproverComment = Choose from the trigger
    • Approval Status Value =Choose from the trigger
    • Approver Claims = Choose from the trigger
Power Automate batch update SharePoint list from power apps

That’s it, now the flow has been created successfully! Save the flow and publish it.

  1. Then add the flow into the Power Apps application by clicking the ellipses[] -> Power Automate ->+ Add flow ->Choose the flow.
add power automate flow into power apps
  1. Now, provide the code below in the bulk updates button control‘s OnSelect property.
update sharepoint online list item using power automate
ForAll(
    Filter(gal_EMPExpenseClaims.AllItems, chk_Select.Value = true,ID),
   MassUpdatesFlow.Run(txt_comment.Text,cmb_approver.Selected.Email,ThisRecord.ID,drp_status.Selected.Value);
);


Notify("Bulk Approvals Done Succesfully!",NotificationType.Success);
Reset(txt_comment);
Reset(cmb_approver);
Reset(drp_status);

Let’s understand the code:

  • gal_EMPExpenseClaims = Gallery control which contains the SharePoint list details.
  • chk_Select = Check box control present in the gallery.
  • txt_comment = Text input control for comment.
  • cmb_approver = Combobox control for selecting approvers.
  • drp_status = Dropdown control to choose the status.
  • Filter(gal_EMPExpenseClaims.AllItems, chk_Select.Value = true, ID) = It returns the IDs of selected items in the gallery.
  • MassUpdatesFlow.Run() = We are calling the Power Automate flow here by passing the below inputs to the flow.
    • txt_comment.Text -> Appover Comment
    • cmb_approver.Selected.Email ->Approver Email
    • ThisRecord.ID -> Selected Item ID
    • drp_status.Selected.Value ->Approval Status
  • ForAll() = This function iterates over each ID returned by the filter function and runs the flow to update the comment, approver name, and approval status in the SharePoint list.
  • Notify() = This function will display a success message once the bulk approvals are complete.
  • Reset() = It will reset the controls.

That’s it; this way, we can perform bulk approvals from the Power Apps application using a Power Automate flow.

Note: In approach 1, the Power Automate flow runs for each selected item. For example, if five items are selected in the gallery, the flow will execute 5 times, once for each item to update them individually.

Power Automate Flow Approach 2:

In this section, we will see another approach that updates the bulk-selected items using a Power Automate flow.

Let’s get started!

  1. Create an Instant cloud flow with a Power Apps trigger as shown below, and provide the following inputs with the mentioned data types:
    • IDs = Text [ Here, we are passing the collection of IDs in a string format i.e, “[1,2,3,4,7]”]
    • Comment = Text
    • Status =Text
    • ApproverEmail = Email
How to easily Update Values in a SharePoint List with Microsoft Power Automate
  1. Now, add a Compose action to convert the IDs string into an array by providing the expression below for the Inputs.
json(triggerBody()['text'])
How to Update Values in a SharePoint List with Power Automate
  1. Then add an Apply to each action and take the output from the compose action. Then, within that, add an Update item action, and provide the following values for the inputs:
    • Site Address = Provide site address.
    • List Name = Provide list name.
    • Id = Select Current item from dynamic content.
    • ApproverComment = Choose from trigger.
    • Approver Status Value =Choose from trigger.
    • Approver Claims = Choose from trigger.
how to perform bulk approvals in power apps using power automate

That’s it, now the flow has been created successfully. Now open the Power Apps application and add that flow init.

  1. Then, add the code below to the button control’s OnSelect property to provide input to the flow.
How to Approve Multiple Power Automate Approval Requests in One Go
// Collect selected IDs into a string
Set(
    varSelectedIDs,
    "[" & Concat(
        Filter(gal_EMPExpenseClaims.AllItems, chk_Select.Value = true),
        ID,
        ","
    ) & "]"
);
//Call the flow by passing inputs
BulkApprovalsFlow.Run(varSelectedIDs,txt_comment.Text,drp_status.Selected.Value, cmb_approver.Selected.Email)

Here:

  • Filter(gal_EMPExpenseClaims.AllItems, chk_Select.Value = true) = This function returns the selected items in the Power Apps gallery.
  • Concat() = This function retrieves the IDs from the filter() function output and adds them with comma-separated values, such as 1, 2, 3, 5, 6.
  • varSelectedIDs = This variable stores the contact function output in a string format, such as “[1,2,3,5,6].”
  • BulkApprovalsFlow.Run() = Here, we are calling the Power Automate flow, passing the collection of IDs in a string format, along with the comment, approval status, and approver’s email.

Now, save the changes and test the app by selecting some records in the gallery, choosing the status and approver, and clicking the bulk approval button. You’ll then see the results in the SharePoint list.

Note: In this approach, the flow will only run once and update the provided input for the selected items in the gallery.

I hope you found this article helpful! In this article, I explain how to perform bulk approvals or updates from Power Apps using a Power Automate flow. Follow this article when you need to perform these operations using flow instead of PowerFx formulas.

Also, you may like:

>

Build a High-Performance Project Management Site in SharePoint Online

User registration Power Apps canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App

Power Platform Tutorial FREE PDF Download

FREE Power Platform Tutorial PDF

Download 135 Pages FREE PDF on Microsoft Power Platform Tutorial. Learn Now…