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 / Update all records in ...
Power Apps
Answered

Update all records in my gallery

(1) ShareShare
ReportReport
Posted on by 171
In power apps, I have a filtered gallery that looks like this.  It works fine. 

SortByColumns(
        Filter(
            View_UK_Campaign_Exclude_Contact,
                (TextSearch1_Title.Text in Title &&
                TextSearch2_Segment.Text in Segment &&
                TextSearch3_VIP.Text in VIP &&
                TextSearch4_UK_Segment.Text in UK_Segment &&
                TextSearch5_Name.Text in Full_Name)),
    "Full_Name"
)

I want to update all selected records in the gallery by hitting a button with the following code. 

ForAll(Gallery2.AllItems,
    Patch(UK_Campaign_Links, LookUp(UK_Campaign_Links, EMail = ThisRecord.EMail), {Campaign_Segment: VarEngagement.Campaign_Segment})
)

This code doesn’t work.  It only updates one record that is not in my current gallery.  Do you have any suggestions why this doesn’t work. 
I have the same question (0)
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,968 Moderator on at
    Hi
     
    A couple of things
     
    1. You don't have anything in your code that validates that the row is highlighed so it won't work how you want it no matter what really
    2. What does selected mean? Personally I use CheckBoxes for them to check for whatever rows they want to do
     
    Let's pretend you have a Checkbox for each row you and make them select it.
    Let's further pretend its called MyCheckBox (yes I am a naming machine)
     
    Then you code would look like this
    The ThisRecord is a pointer to the Internal loop of Gallery Items, so you dont need to do a Lookup on the row, just use ThisRecord
     
    Now i personally like to use ThisRecord even in my assignment (where you have VarEngagement). 
     
    ForAll(Filter(Gallery2.AllItems, MyCheckBox.Value = true),
        Patch(UK_Campaign_Links, ThisRecord,
         {
             Campaign_Segment: ThisRecord.VarEngagement.Campaign_Segment
         }
       )
    );
     
    And Voila. done
     
  • Fuzzy1 Profile Picture
    171 on at
    Thanks for your response.  
     
    That is how I did it before.  
     
    I want to filter the gallery and update all the records in the table with the new campaign segment. 
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,968 Moderator on at
    Then the only difference in what I gave you and what you want it, don't add the filter
     
    Just change it to 
     
    Gallery.AllItems
     
    And it will work exactly as you want it. However you specifically said, I want to do it based on all the Selected Records, which mean you have to filter it. If you wanted all, say that

    Your code is broken and not correct because of what you wrote, what I gave you works perfectly if you dont want it filtered, remove the filter syntax
  • Verified answer
    Fuzzy1 Profile Picture
    171 on at
    Thanks for your help. 
     
    I have to give kudos to Co Pilot.  I love this tool and us it all the time and it helped me fix my problem.  I put my solution below.  
     
    ForAll(
        Gallery2.AllItems,
        Patch(UK_Campaign_Links,
            Defaults(UK_Campaign_Links),
            {
                EMail: EMail,
                Contact_Id: Id,
                Campaign_Segment: VarEngagement.Campaign_Segment,
                Created_By: User().FullName,
                Created_Date: Today()
            }
        ));
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,968 Moderator on at
    That answer makes no sense.
     
    You asked how to PATCH a record, not create them.
     
    I gave you the solution for how to Patch them, you wrote a CoPilot for Creating them..
     
     
    Not the answer to your question at all.

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 335 Most Valuable Professional

#2
11manish Profile Picture

11manish 166

#3
sannavajjala87 Profile Picture

sannavajjala87 71 Super User 2026 Season 1

Last 30 days Overall leaderboard