cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jayant2
Helper V
Helper V

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 III
Super User III

@Jayant2 

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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

2 REPLIES 2
RandyHayes
Super User III
Super User III

@Jayant2 

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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

Jayant2
Helper V
Helper V

@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 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

PA Community Call

Power Apps Community Call

Next call is happening on April 21st at 8a PST.

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (61,322)