cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Bulk Update and Single Record Update

Hi All,

 

i have 2 requirements from business stahleholders to incorporate bulk update and single record update. 
Source: Excel.

I have prepared grid view with the data and also incorporated Bulk upload functionality but there is one issue with the code. 
My gallery is filterable by 4 dropdowns and below is the code for gallery:

If(Dropdown3.Selected.Result = "All UJR" && Dropdown3_3.Selected.Result = "All Competency" && Dropdown3_1.Selected.Result = "All Trainings" && Dropdown3_2.Selected.Result = "All Employees",exceldata,
Filter(exceldata, If(Dropdown3.Selected.Result <> "All UJR",UJR = Dropdown3.Selected.Result) ||If(Dropdown3_3.Selected.Result <> "All Competency",'Competency ' = Dropdown3_3.Selected.Result) || If(Dropdown3_1.Selected.Result <> "All Trainings",Training = Dropdown3_1.Selected.Result) || If(Dropdown3_2.Selected.Result <> "All Employees",EMPNAME = Dropdown3_2.Selected.Result) ))

 The above code states if dropdown value is equal to respected value then show all data if not filter by respected dropdown.

Now my update button has the below code:

If(Checkbox1.Value = true,ForAll(Gallery3.AllItems,UpdateIf(Table1,uniqueid = ThisRecord.uniqueid, {Status:"Completed"})))

 This code works but it updates all the records even though i have filtered the gallery by any one dropdown. What change should i make so that the update button updates only those filtered records in the gallery and not all records.

 

There is another requirement to update single record by selecting a record through check box and updating the record status value and then save that data. How do i achieve that. I have added checkbox on gallery record and on selection of check box i show dropdown value that allows user to select the record and change status value. After changing i want to patch the data onselect of a save button. How do i achieve that?

Including image of gallery and save button along with bulk update button:

Jayant2_1-1613566424797.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@Anonymous 

First please consider changing your Gallery Items Formula to the following:

Filter(exceldata,
    (Dropdown3.Selected.Result = "All UJR" || UJR = Dropdown3.Selected.Result) &&
    (Dropdown3_3.Selected.Result = "All Competency" || 'Competency ' = Dropdown3_3.Selected.Result) &&
    (Dropdown3_1.Selected.Result = "All Trainings" || Training = Dropdown3_1.Selected.Result) &&
    (Dropdown3_2.Selected.Result = "All Employees" || EMPNAME = Dropdown3_2.Selected.Result)
)

It's a bit easier for you to maintain and read.

 

For your Update button, your Formula should be:

If(Checkbox1.Value, ForAll(Gallery3.AllItems As _item, UpdateIf(Table1, uniqueid = _item.uniqueid, {Status: "Completed"})))

The reason that it is updating all records is because you were using ThisRecord in your formula.  In the context of the Formula you had before, ThisRecord would be referring to the record of the UpdateIf, not to the Gallery records...so, for every record, the criteria for the updateif would have been true.

Also, from a user interface perspective, I would consider making the Update button disabled if the checkbox is not checked.  You can do this on the DisplayMode property of the button : If(Checkbox1.Value, Edit, Disabled)

This way users are not confused that they clicked the button but nothing happened (as you have the If statement in your OnSelect and will do nothing if not checked).  You can then remove the If part from your OnSelect of the button.

 

As for your next "to update single record by selecting a record through check box and updating the record status value and then save that data."  Again I would reconsider the approach on this.  Instead of all of those steps, consider a Save icon on your row in the Gallery.  Have the DisplayMode be disabled if the record is not changed and enabled when changed.  Then on the OnSelect of that icon, the following formula:

UpdateIf(Table1, uniqueid = ThisItem.uniqueid, {Status: "Complete"})  (assuming that is what you want to update)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

2 REPLIES 2
RandyHayes
Super User
Super User

@Anonymous 

First please consider changing your Gallery Items Formula to the following:

Filter(exceldata,
    (Dropdown3.Selected.Result = "All UJR" || UJR = Dropdown3.Selected.Result) &&
    (Dropdown3_3.Selected.Result = "All Competency" || 'Competency ' = Dropdown3_3.Selected.Result) &&
    (Dropdown3_1.Selected.Result = "All Trainings" || Training = Dropdown3_1.Selected.Result) &&
    (Dropdown3_2.Selected.Result = "All Employees" || EMPNAME = Dropdown3_2.Selected.Result)
)

It's a bit easier for you to maintain and read.

 

For your Update button, your Formula should be:

If(Checkbox1.Value, ForAll(Gallery3.AllItems As _item, UpdateIf(Table1, uniqueid = _item.uniqueid, {Status: "Completed"})))

The reason that it is updating all records is because you were using ThisRecord in your formula.  In the context of the Formula you had before, ThisRecord would be referring to the record of the UpdateIf, not to the Gallery records...so, for every record, the criteria for the updateif would have been true.

Also, from a user interface perspective, I would consider making the Update button disabled if the checkbox is not checked.  You can do this on the DisplayMode property of the button : If(Checkbox1.Value, Edit, Disabled)

This way users are not confused that they clicked the button but nothing happened (as you have the If statement in your OnSelect and will do nothing if not checked).  You can then remove the If part from your OnSelect of the button.

 

As for your next "to update single record by selecting a record through check box and updating the record status value and then save that data."  Again I would reconsider the approach on this.  Instead of all of those steps, consider a Save icon on your row in the Gallery.  Have the DisplayMode be disabled if the record is not changed and enabled when changed.  Then on the OnSelect of that icon, the following formula:

UpdateIf(Table1, uniqueid = ThisItem.uniqueid, {Status: "Complete"})  (assuming that is what you want to update)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Anonymous
Not applicable

@RandyHayes Thank you for the solution. It worked like a charm.

But, for the single record update, the users are still looking for the functionality to update through check box. 
requirement: select a record by checking the box inside gallery row and updating all the records at once through a button outside gallery.

How can we achieve that, i am still stuck at the formula for that.

 i am using  the below formula but it keeps showing error to me. Hope you can help me out.

 

ForAll(Filter(Gallery3.AllItems As _items, Checkbox2.Value= true), UpdateIf(Table1,uniqueid = _items.uniqueid, {Status:"Assigned"}))

 

 

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (2,988)