Problem Statement
I am working on automating the process of sending leave resumption notices to staff to confirm their return. Currently, I am using the "Get Items" action to retrieve a list of items from a SharePoint list. However, I am encountering an issue with the approval workflow within the "Apply to each" action.
Challenge:
For each of the 53 items retrieved from the SharePoint list, I need to trigger 53 independent approval requests, each sent to the corresponding recipient’s email address (one per item). The current setup processes these requests sequentially, causing the flow to wait for each approval email to complete before proceeding to the next item. This results in delays.
Objective:
I need the approval requests to be sent concurrently rather than sequentially to ensure all 53 recipients receive their emails independently and without delay.
I’d appreciate any guidance or best practices to achieve this.
---------------------------------------------------------------------
To achieve concurrent approval requests in Power Automate for
each item retrieved from a SharePoint list, you can use a parallel branching
approach. Below is a general outline of how you can set this up in Power
Automate:
Solution Outline
1.
Trigger: Use a trigger to
start the flow, such as "When an item is created" or "When an
item is modified" in the SharePoint list.
2.
Get Items: Use the "Get
items" action to retrieve all the items from the SharePoint list.
3.
Apply to Each: Use the "Apply
to each" action to iterate over the retrieved items.
- Inside
the "Apply to each" action, use the "Start and wait for an
approval" action.
4.
Concurrency Control: Adjust the
concurrency control settings of the "Apply to each" action to allow
parallel processing.
Step-by-Step Guide
Step 1:
Create a new Flow
- Go
to Power Automate (https://flow.microsoft.com/).
- Click
on "Create" and select "Automated flow".
- Choose
a trigger, such as "When an item is created" or "When an
item is modified" for your SharePoint list.
Step 2: Get
Items from SharePoint
- Add
a new action and search for "SharePoint".
- Select
the "Get items" action.
- Configure
the "Get items" action to point to your SharePoint list.
Step 3:
Apply to Each
- Add
an "Apply to each" action.
- Set
the "Output" field to the value from the "Get items"
action (usually
value
).
Step 4:
Start Approval Process
- Inside
the "Apply to each" action, add a "Start and wait for an
approval" action.
- Configure
the "Start and wait for an approval" action:
- Set
the "Approval type" to "Approve/Reject - First to
respond".
- Set
the "Title" and "Assigned to" fields accordingly
(e.g., use dynamic content to assign to the appropriate email address).
Step 5:
Enable Concurrency Control
- Click
on the "Apply to each" action to open its settings.
- In
the settings pane, turn on "Concurrency Control".
- Set
the "Degree of Parallelism" to a suitable number (e.g., 20).
This number controls how many approval requests can be processed
concurrently.
Step 6: Save
and Test the Flow
- Save
the flow.
- Test
the flow by creating or modifying items in the SharePoint list.
Example Flow Configuration
Here
is an example of how the flow might look:
- Trigger: When an item is created in SharePoint.
- Get Items: Retrieve items from the SharePoint list.
- Apply to Each:
- Start and Wait for an Approval:
- Title: "Leave Resumption
Approval"
- Assigned to:
item.email
(Use dynamic content to assign to the recipient's email).
PowerShell Solution
If
you prefer to use PowerShell, you can use the PnP PowerShell module to retrieve
the items and send approval emails. Below is an outline of the PowerShell
script:
Install PnP
PowerShell Module
PowerShell Script
Summary
Using
Power Automate with parallel branching or PowerShell with a loop, you can send
concurrent approval requests to each recipient. The key in Power Automate is to
enable concurrency control in the "Apply to each" action. This
ensures that all recipients receive their approval requests independently and
without delay.
No comments:
Post a Comment