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 / powerapps patch on gal...
Power Apps
Unanswered

powerapps patch on gallery using checkbox to update sharepoint list

(0) ShareShare
ReportReport
Posted on by 25

Hi i have strange issue in powerapps building in teams using shp as datasource.

i have master checkbox outside gallery with  oncheck property :updatecontext({var:true});

                                                     set(var,!var);if(var,clearcollect(colup,filter(datsource,cc = combobox1.selected.result or dd = combobox2.selected.result)),clear(colup));

set(editing,true);

on uncheck updatecontext({var:false})

inside gallery for each item i have checkbox onchecking mastercheckbox inside checkboxes are selected onuncheck checkboxes are unchecked

inside checkbox

checked : var

oncheck : collect(colup,thisitem); --- another collection 

onuncheck : remove(colup,thisitem);

on select : set(editing,true)

i have comments in gallery which take multiline text  for each item onchange : collect(col2,true) --- one colection 

                                                                                                             displaymode : if(editing,edit,view)

if oncheck on checkbox  outside gallery all checkbox inside gallery is selected viceversa

on submitbutton 

onselect property:

updateif(colup,true,{op :combobox2.selected.value});

clearcollect(colda,showcolumns(colup,"ID","op"));

patch(datasource,colda);

clear(col2);

forall('gallery'.allitems,collect(col2,{id:value(label.text),comments:textbox.value}));

patch(datasource,col2);

updatecontext({var:true});

updatecontext({var:false});

  THE ISSUE WHEN I CLICKING ON SUBMIT BUTTON PATCH IS HAPPENING ON ONE COLLECTION ON ANOTHER COLLECTION FOR COMMENTS PATCH IS HAPPENING SOMETIMES TO SHAREPOINT LIST SOMETIMES NOT. why is issue,could any help where i need to modify my code.

 

Categories:
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @anonypower 

    You are using a context and a global variable with the same name.  This is going to cause you confusion as to which variable you are working with.  Choose one or the other or rename, or better yet, get rid of all the variables and collections as you don't need any of them.  Your controls in your app already have all the information you need, you don't need to duplicate it into static variables or collections.

     

    Please consider the following changes to your formulas:

    On the CheckBox in the Gallery, set the Default property to yourOutSideCheckbox.Value

    On the OnSelect of your button:

    Patch(datasource, 
     Forall(Filter('gallery'.AllItems, checkBox.Value), 
     {ID: ID, 
     comments: Textbox.Value
     op: combobox2.Selected.Value
     } 
     ) 
    );
    

     

    Set the DisplayMode on the Gallery TextInput controls to : If(galleryCheckBox.Value, Edit, View)

     

    I hope this is helpful for you.

  • anonypower Profile Picture
    25 on at

    am using collections and variables for

    1.want to update a column value  as bulk update for each item which is selected  from outside checkbox and inturn inside checkbox.

    2.at same time a want write comment against each item with different comments 

    for example if select 10 records from outside check box which select 10 opt column is populated with same value and comment value is populated with differernt text against each item.

    so when i select on select at a time same value for opt column is populated and and differernt value against each item,that is why i created  variable and collections .my environment for building app is teams .

     

  • anonypower Profile Picture
    25 on at

    hi  the forall function with patch is happening slow .how to overcome it as you are saying collection and variables will make powerapp complicate.provide possible solution above question .Thank you for your reply.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @anonypower 

    The formula provided will give the best results you can get.

    It doesn't really make much difference in the patching - when you have a table of records to update, providing a table is more efficient.  This comes from the ForAll.  However "more" is a relative term.  Regardless of the method, when there are multiple items to update, PowerApps will still do this row by row.  The only difference (and where you get "more") is that there is no lookup involved and the matching of records is offloaded to the cloud service instead of your app.

    BUT, if you have a large number of items to update - it will take time.  It is by no means "quick".

    Trying to change the formula to work with a collection would have no impact at all because it will still need to do the same process.  The only difference with the collection is that at some point in your app you are also going to incur the performance cost of loading that collection.

     

    The only other option for bulk update is to package all the update records into a JSON argument of a PowerAutomate flow and let flow do the updates.  BUT...it really would just offload the updating to another place with the same amounts of time being taken someplace else.

  • anonypower Profile Picture
    25 on at

    Providing table is more efficient   --- could you reflect on it. As business users are getting confused while using app because records are updating one by one on checkbox selection. THANK YOU FOR ELABORATE REPLY.COULD YOU REFLECT ON ABOVE QUESTION PLEASE.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @anonypower 

    As mentioned, UpdateIf, Patch, RemoveIf, Remove, etc...will ALL perform their actions on a record by record basis.

    The only way to speed that process up is to reduce any overhead to it.  When you supply a table of all the updates to do, there is no additional overhead to lookup the record with other criteria.

     

    However...these things are USUALLY pretty quick.  If there are only a couple of rows to patch, then the user should not notice any delay.  If there is a large number to do, then it will cause user confusion that you must design into your app - things like a twirling doughnut, screen blacker, please wait, etc. to let them know that something is happening.

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 352 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 323

#3
Mohsin Ali Profile Picture

Mohsin Ali 226

Last 30 days Overall leaderboard