Solution 1: Sequential Processing in Power Apps (Recommended)
Replace your ForAll with a sequential loop to eliminate concurrency:
javascript
// Instead of ForAll, use a sequential approach
For(attachment in AttachmentCollection,
'Power Automate Flow'.Run(
SharePointItemID,
attachment.Name,
attachment.Value
);
// Small delay between calls (optional)
// Wait(100)
);
Solution 2: Batch Processing in Power Automate
Modify your Power Automate flow to handle multiple attachments in a single call:
-
Change your Power Apps call to send all attachments at once:
javascript
'Power Automate Flow'.Run(
SharePointItemID,
JSON(AttachmentCollection)
);
-
In Power Automate, use a "Parse JSON" action to handle the attachment array
-
Use "Apply to each" with concurrency control:
-
In the "Apply to each" action settings
-
Turn OFF "Configure run after"
-
Set concurrency control to 1 (forces sequential processing)
Solution 3: Power Automate Retry Logic + Delay
Add retry logic to your existing flow:
-
Add a "Delay" action before your "Add attachment" action:
delay(rand(1000, 3000)) // Random delay 1-3 seconds
-
Configure retry policy on your "Add attachment" action:
-
Click the "..." menu on the action
-
Settings → Configure run after
-
Check "has failed" and "has timed out"
-
Set retry policy: Count = 3, Interval = PT10S
Solution 4: Queue-Based Processing (Advanced)
For high-volume scenarios, implement a queue system:
-
Power Apps sends all attachments to a SharePoint "Queue" list
-
Power Automate processes queue items sequentially
-
Use a scheduled flow that runs every few minutes to process queued items
Code Implementation for Solution 1 (Most Practical):
javascript
// In your Power Apps OnSelect or OnSuccess
ClearCollect(ProcessingResults, Blank());
For(i in Sequence(CountRows(AttachmentCollection)),
Set(CurrentAttachment, Index(AttachmentCollection, i));
Set(FlowResult,
'YourPowerAutomateFlow'.Run(
SharePointItemID,
CurrentAttachment.Name,
CurrentAttachment.Value
)
);
Collect(ProcessingResults, FlowResult);
);
// Show completion message
Notify("All attachments processed successfully", NotificationType.Success);
If I have answered your question, please mark it as the preferred solution ✅ . If you like my response, please give it a Thumbs Up 👍.
Regards,
Riyaz