cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MAV_CB
Microsoft
Microsoft

Editing multiple records in Gallery control

Anyone have any tips and tricks for doing a multiple record update? I have a Gallery loading SharePoint list items and I want to be able to update multiple records at once (such as deleting records that have a checkbox in their gallery record ticked). Another scenario is where each record has a Yes/No column where I am using a Checkbox as the control, and want users to tick/untick boxes record by record and "Save" those changes.

16 REPLIES 16
hpkeong
Community Champion
Community Champion

Hi @MAV_CB

 

I have posted one of Useful Features of PowerApps (15): Multiple / Batch Records Editing.

 

https://powerusers.microsoft.com/t5/PowerApps-Forum/Useful-features-of-powerapps-15-Multiple-Batch-R...

 

Hope this helps

hpkeong

View solution in original post

Anonymous
Not applicable

hi @hpkeong,

 

You gave me some recommendations in this topic. İt worked. Now, I try to work wtih more complex example, I tryed to many method, but ı didnt work it. could you help me? ı will try to explain it;

 

there is a browsegallery on my screen and it has radio button as extra.  I will update item, if my database has this item primary key(actually not only primary key; name and date value are important for change it), after user select every selection. I used ForAll and Updateif function. There is example in the below, but it didnt work.

 

ForAll(bg_anket.AllItems; UpdateIf(AnketUygulamasi_Sonuclari;And(Anket_Tarihi=dp_tarih.SelectedDate;dd_sube.Selected.Value=SubeAdi);
{SubeAdi:dd_sube.Selected.Value;
DolduranKisi:txt_usermail.Text;  

 

Also, generally powerapps slowly work, if ı use browsegallery and if  ı save all the one time, it works more slowly. Do you know how can it work more fast it ?

 

Could you give me any advice? Thank you.

@Steelman70, I must say - this is REALLY clever stuff - I'm impressed. It really solved one of my big issues with some checklists in Powerapps. Lots of checkboxes in galleries - the solution is now performing much faster.

 

I have found one strange thing, that maybe you can provide som input on:

My gallery filters a Sharepoint list: Items = Filter(Service_CompletedCheckItems,ServiceReportID = Value(txtReportID.Text))

 

The items on this list are generated by a MS Flow when a record is inserted in another table (so not from within Powerapps).

 

Here's the thing: If some records are generated AFTER the data connection was last refreshed, then entering the screen with the above filter will actually show all the newly insterted records - withour a refresh, but the UpdateIf command will not work until after a refres of the data connection has been performed - strange right.

The refresh takes a significant amount of time, so I would prefer not having to do it - any ideas?

 

Here's my update statement: UpdateIf(Service_CompletedCheckItems,ID in ItemToUpdate, {Completed: LookUp(Gallery1_1.AllItems, ID = Service_CompletedCheckItems[@ID]).Checkbox1.Value,CheckpointValue: LookUp(Gallery1_1.AllItems, ID = Service_CompletedCheckItems[@ID]).TextInput1_1.Text})

Meneghino
Community Champion
Community Champion

Hi @Debug_Bug

 

This is still Steelman70, but I just changed identity.

 

I am surprised that the gallery shows the records generated after the data connection was last refreshed, I cannot imagine how this can happen without any action on your part.  But maybe it happens if you change the value of textReportID.Text, therefore triggering a new query.  Is that the case?  Otherwise, without any change in txtReportID.Text you should not see a fresh set of data.

 

Regarding the UpdateIf, the issue may be linked more to delegation than fresh data, and with the collection mechanics.  The in operator is not delegated.  I would therefore suggest a different approach, also given also what I have learned in the meanwhile.

 

You can reference the selected (or unselected) records in your gallery via the AllItems propery of the gallery.  This works extremely well normally.  So for example your list of records to update could be something like:

Filter(Gallery1_1.AllItems, Checkbox1.Value)

This works since Checkbox1.Value is boolean.  And it avoids collecting the ID's to update.

 

Hence you could simply update your records with either a Patch statement using table arguments or a ForAll loop on the filtered gallery items.  If you are not clear how either of the two options could work, please post back.

 

Hi @Meneghino

Thanks for the reply. I will try your suggestion tomorrow and see how it performs. Thanks.

 

But, I have a very hard time getting decent performance out of the Sharepoint lists I'm using to store data in the current solution, so I think I will be moving to SQL server instead - but anyway, your input is extremely valuable - I will still need it for the SQL server.

I will report back with findings, thanks again.

Hi @Meneghino.

 

I have now switched my app over to SQL (instead of Sharepoint) to be able to generate the checklists using stored procedures for server-side exection, so it's now much faster.

 

I'm using you brilliant way with collecting the changes:

If(CountRows(Filter(ItemToUpdate, Id = ThisItem.ID)) = 0, Collect(ItemToUpdate, {Id: ThisItem.ID}))

 

and then the UpdateIf afterwards

UpdateIf('[dbo].[SE_Service_CheckListItems]',ID in ItemToUpdate, {Completed: LookUp(galChecklistItems.AllItems, ID = '[dbo].[SE_Service_CheckListItems]'[@ID]).chkCompleted.Value,CheckpointValue: LookUp(galChecklistItems.AllItems, ID = '[dbo].[SE_Service_CheckListItems]'[@ID]).txtCheckpointValue.Text})

 

This has been working very well and I need to update both checked and unchecked records, so this is a great way for me.

But this morning, the UpdateIf no longer works - nothing happens on click?? This has almost got to be a server side error - I have checked that the UpdateContext works as intended and it gets filled with the right records.

Have you ever seen something like this - are yours still working?

 

I changed nothing in the app and it was working last night. It has failed on all platforms (PC, iPhone, iPad).

Meneghino
Community Champion
Community Champion

Hi @Debug_Bug

Two things come to mind.

1) I think the 'in' operator is not actually yet delegated in SQL Server, so you may be running into issues there

2) The SQL Server connector in PowerApps is in constant development, so that I have experienced such issues

I am fairly confident that MS are working hard to improve the connector and I can see improvements on it every 3-4 weeks, even though sometimes it is two steps forward and one back.

 

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (52,047)