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.
Solved! Go to Solution.
Hi @MAV_CB
I have posted one of Useful Features of PowerApps (15): Multiple / Batch Records Editing.
Hope this helps
Here is an idea, please let me know if anything is unclear, need more details, or you get stuck.
1) Use the Collect function to create a collection (MyCollection) of the item IDs that you need to delete/update, for example by adding/removing the item to/from the MyCollection when the box is ticked/unticked in the gallery
2) For the delete button (outside the gallery) set the OnSelect to use the RemoveIf, where the condition is that the records are in MyCollection or alternatively use the Remove( DataSource, MyCollection [, All ] ) type of syntax
3) For the save all changes button (outside the gallery) set the OnSelect to UpdateIf, where the condition is that the records are in MyCollection
Find out more about these functions here:
https://powerapps.microsoft.com/en-us/tutorials/working-with-variables/#create-a-collection
https://powerapps.microsoft.com/en-us/tutorials/function-remove-removeif/
https://powerapps.microsoft.com/en-us/tutorials/function-update-updateif/
Hi,
I can make the 2) removing multiple items at once work, but could not solve how to update multiple records.
This is how I did the number 2:
- On each item there is a thrashbin icon:
OnSelect = If(CountRows(Filter(ItemToRemove, Id = ThisItem.Id)) = 0, Collect(ItemToRemove, ThisItem), RemoveIf(ItemToRemove, Id=ThisItem.Id))
- To highlight the selected, I did this:
Fill = If(CountRows(Filter(ItemToRemove, Id = ThisItem.Id)) = 0, White, DarkRed)
And the formula for the remove button:
RemoveIf('[dbo].[Table1]',Id in ItemToRemove);Clear(ItemToRemove)
This is how I tried to do the number 3 (updating multiple items):
- On each control in a row I added:
OnChange = If(CountRows(Filter(ItemToUpdate, Id = ThisItem.Id)) = 0, Collect(ItemToUpdate, {Id: ThisItem.Id}))
- To save I tried this (doesn't highlight an error - but doesn't work):
OnSelected = UpdateIf('[dbo].[Table1]',Id in ItemToUpdate, Gallery1.Updates);Clear(ItemToUpdate);Refresh('[dbo].[Table1]')
The problem is that syntax of UpdateIf requires that you should be able to create pairs of conditions and records:
UpdateIf( DataSource, Condition1, ChangeRecord1 [, Condition2, ChangeRecord2, ... ] )
It would work if I could do foreach loop or something.
Any ideas?
Hi, this is getting interesting, hopefully I can get some kudos for this! Let me take your two points in two different posts.
Number 2:
Your approach is good and works, well done. However, I have since discovered a simpler approach which avoids the use of a collection and uses a checkbox control in the gallery. The key is that you can refer to the value of a control in a gallery directly! You use the disambiguation operator @ to match the ID in the gallery to the ID in your source!
Hopefully this will be clear from the following screenshot, but please let me know if it is not.
There may be even better approaches by filtering the source by the checkbox before removing all items, but I haven't tried this yet.
Number 3:
Hopefully you will be really impressed by this one, the approach is the same as for 2. I use your approach for the collection.
I have not used the Updates property of Gallery1 because frankly I only first noticed it in your post. Let me see if that can yield an even better result. In any case again please let me know if anything is not clear. By the way, if you have more than one field to update, you use the inline syntax
Thanks!
I confirm that with the instructions I could make both cases work. 🙂
Multiple updates saved with one click is one of the key use cases on the PoC I'm working on. It is so important from the usability perspective.
Hi @opax,
I try to work on same senario. it's works when database is collectipn. But my database is Common Data Model and function is:
UpdateIf('ListA',ogr_no<>"", {durum:LookUp(BrowseGallery1.AllItems, ogr_no='ListeA'[@ogr_no]).checkbox1.Value})
Do you have any idea?
Thanks & Regards
Hi @Anonymous
I have posted one of Useful Features of PowerApps (15): Multiple / Batch Records Editing.
Hope this helps.
Hi @opax
I have posted one of Useful Features of PowerApps (15): Multiple / Batch Records Editing.
Hope this helps
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.
User | Count |
---|---|
207 | |
97 | |
60 | |
51 | |
44 |
User | Count |
---|---|
257 | |
160 | |
85 | |
78 | |
57 |