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 / Only patch one records...
Power Apps
Answered

Only patch one records eventhough toggle of other records are also true

(0) ShareShare
ReportReport
Posted on by 254

Hello,

 

I'm using a gallery to select each record which I want to patch data over OnSelect property of a button. 

If (Toggle2.Value = true && !IsBlank(Trim(TextInput2_3.Text));
 Patch(
 ControlTask;
 LookUp(
 ControlTask;
 ID = Gallery.Selected.ID
 
 );
 {
 Comment2: TextInput2_3.Text;
 Control2:true;
 Feedback2:TimeValue(Label10);
 User2: User().Email
 }
 );;Notify("Thank you for submit of data!");
 Notify("Please fill out comment and switch toggle to YES";Error))

 

I actually have only two conditions: Toggle needs to be on "YES" and "Comments" Field cannot be empty. Thats all. 

But even when several records in that Gallery meets that two conditions, it only patches one of those records. (Strangely always that one with the smaller ID)

 

Hope someone can point me to the right direction...I also tried with ForAll - function before the  Patch(), but even when syntax seemed right nothing happened. Records where not patched.

 

Thank you very much in advanced. 

Best. 

Categories:
  • Verified answer
    Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @Applicable88 

    There are several ways to go.  First, you can patch the record with an icon on the same line, immediately, with your formula

    If (Toggle2.Value = true && !IsBlank(Trim(TextInput2_3.Text));
     Patch(
     ControlTask;
     ThisItem;
     {
     Comment2: TextInput2_3.Text;
     Control2:true;
     Feedback2:TimeValue(Label10);
     User2: User().Email
     }
     );;Notify("Thank you for submit of data!");
     Notify("Please fill out comment and switch toggle to YES";Error))

    Another approach is to add the record to a collection and then patch the collection all at once. As long as the ID column of the record is included in the collection and the column names are identical, Patch(datasource, collectionname) will update the records very quickly.  See https://www.matthewdevaney.com/patch-multiple-records-in-power-apps-10x-faster/ 

  • Applicable88 Profile Picture
    254 on at

    @Drrickryp thanks for the link. 

    I particularly interested in the possiblities of patching several items simultaneously. But even tho I have matched with the ID the it either only patch one item at a time  or (with your second method) updating every row in the collection with the new value. 

    According to the link: 

    Having a toggle I can use following

    Patch(colControle, ThisItem, {Attended: Toggle1.Value})

    Since it only toggles one item I did the following on onchange of toggle: 

    UpdateIf(
    RenameColumns(colControl;
    "ID";"EID");
    ThisItem.ID =EID;
    {Controle2:true}
    )

    It patch every item/row in the collection, but I wanted it to only patch those where ID and the new renamed EID are matching. EID is for avoiding ambiguity. 

     

    You have any idea where lies the mistake? Or is it simply the reaction of a gallery the problem?

     

    Best. 

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 July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 402 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 296 Most Valuable Professional

Last 30 days Overall leaderboard