ForAll() is one of the most powerful — and most misunderstood — functions in Power Apps.
It enables looping, bulk operations, and batch processing, but misuse can cause performance issues, delegation warnings, and unpredictable behavior.

This article explains how ForAll() actually works, when to use it, when not to use it.

1. What is ForAll()?

ForAll() iterates over each record in a table and evaluates a formula for each one.

Code
ForAll(
    Table,
    Formula
)

2. Understanding How ForAll() Executes

3. Bulk Patch to SharePoint List

Scenario

Update multiple list items selected in a gallery.

Code
ForAll(
    Gallery1.SelectedItems,
    Patch(
        Feedback,
        ThisRecord,
        {
            Status: "Approved",
            ApprovedBy: User().Email,
            ApprovedOn: Now()
        }
    )
)

4. Creating New Records in Loop

Scenario

Create task items for each selected user.

Code
ForAll(
    colUsers,
    Patch(
        Tasks,
        Defaults(Tasks),
        {
            Title: UserName,
            AssignedTo: UserEmail
        }
    )
)

5. ForAll + Collect Pattern (In-Memory Processing)

Scenario

Build a transformed dataset before saving.

Code
ClearCollect(
    colPreparedData,
    ForAll(
        SourceCollection,
        {
            Title: ThisRecord.Name,
            IsActive: ThisRecord.Status = "Active"
        }
    )
)

6. Updating Multiple Lists Safely

Scenario

Patch two lists per record.

Code
ForAll(
    colItems,
    With(
        {
            updatedItem: Patch(
                Orders,
                ThisRecord,
                { Status: "Processed" }
            )
        },
        Patch(
            AuditLog,
            Defaults(AuditLog),
            {
                OrderId: updatedItem.ID,
                Action: "Processed"
            }
        )
    )
)

7. Conditional Processing Inside ForAll

Scenario

Only update items matching a condition.

Code
ForAll(
    colItems,
    If(
        Quantity > 0,
        Patch(
            Inventory,
            ThisRecord,
            { InStock: true }
        )
    )
)

8. Delegation Rules with ForAll

Delegation Warning

ForAll() itself is not delegable.

Code
ClearCollect(
    colPending,
    Filter(LargeList, Status = "Pending")
);

ForAll(
    colPending,
    Patch(...)
)

9. ForAll with Attachments

Scenario

Copy attachments from one list to another.

Code
ForAll(
    AttachmentControl.Attachments,
    Patch(
        TargetList,
        Defaults(TargetList),
        {
            Title: ThisRecord.Name,
            Attachments: ThisRecord.Value
        }
    )
)

10. Error Handling in ForAll()

Code
ForAll(
    colItems,
    IfError(
        Patch(TargetList, ThisRecord, { Status: "Done" }),
        Collect(
            colErrors,
            {
                ItemId: ThisRecord.ID,
                Error: "Patch failed"
            }
        )
    )
)

Conclusion

ForAll() is powerful — but it should be the last step in your pipeline, not the first.

When NOT to use ForAll()