web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Updating database from...
Power Apps
Answered

Updating database from collection in a ForAll

(1) ShareShare
ReportReport
Posted on by 40

Hi all

 

I have a collection, allowing user to update all data then save all.

I use a ForAll to add or update all. However, the update only updates the first record with data from the last record.

Seems like ThisRecord.id is from first and .name is from last.

 

What is wrong here?

 

    ForAll(palletList,        
        If(ThisRecord.id=Blank(),
            Notify(Concatenate("Pallet add", ThisRecord.item),NotificationType.Success,500);
            Patch(outbound_pallets, Defaults(outbound_pallets),
                { pallet_id: ThisRecord.pallet_id,
                item: ThisRecord.item,
                quantity: ThisRecord.quantity,
                comment: ThisRecord.comment,
                trip_id: tripList.Selected.id }),
            // else
            Notify(Concatenate("Pallet update ", ThisRecord.id, ",", ThisRecord.item, ",",ThisRecord.quantity),NotificationType.Error,500);
            Patch([@outbound_pallets], LookUp(outbound_pallets, id=ThisRecord.id),
                { pallet_id: ThisRecord.pallet_id,
                item: ThisRecord.item,
                quantity: ThisRecord.quantity,
                comment: ThisRecord.comment,
                trip_id: tripList.Selected.id });
        );
    );
 
Categories:
I have the same question (0)
  • mmbr1606 Profile Picture
    14,629 Super User 2026 Season 1 on at

    hey @SonnichJensen 

     

    can u try this:

    ForAll(palletList,
     If(IsBlank(ThisRecord.id),
     Notify(Concatenate("Pallet add: ", ThisRecord.item), NotificationType.Success, 500);
     Patch(outbound_pallets, Defaults(outbound_pallets),
     {
     pallet_id: ThisRecord.pallet_id,
     item: ThisRecord.item,
     quantity: ThisRecord.quantity,
     comment: ThisRecord.comment,
     trip_id: tripList.Selected.id
     }),
     Notify(Concatenate("Pallet update: ", ThisRecord.id, " Item: ", ThisRecord.item, " Qty: ", ThisRecord.quantity), NotificationType.Information, 500);
     Patch(outbound_pallets, LookUp(outbound_pallets, id = ThisRecord.id),
     {
     pallet_id: ThisRecord.pallet_id,
     item: ThisRecord.item,
     quantity: ThisRecord.quantity,
     comment: ThisRecord.comment,
     trip_id: tripList.Selected.id
     });
     )
    );
    

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

  • SonnichJensen Profile Picture
    40 on at

    Can you say what you changed?

  • Verified answer
    SonnichJensen Profile Picture
    40 on at

    I nailed it.

    ThisRecord refers to the item it is in, so ThisRecord within the LookUp is is for the present record within the LookUp. Therefore id=ThisRecord.id is always true.


    The solution comes with the keyword As

     

    ForAll(palletList As pl,
    ...
                // else
                Patch([@outbound_pallets], LookUp(outbound_pallets, id=pl.id),
                    { pallet_id: pl.pallet_id,
                    item: pl.item,
                    quantity: pl.quantity,
                    comment: pl.comment,
                    trip_id: tripList.Selected.id });
            );
        );

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 316 Most Valuable Professional

#2
11manish Profile Picture

11manish 242

#3
Valantis Profile Picture

Valantis 198

Last 30 days Overall leaderboard