cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rknight
Helper II
Helper II

Updating multiple SharePoint List records with ForAll and Patch - not working

Hey everyone!

 

Got an inventory app to track cables. What I have so far is a gallery of the SharePoint List with checkboxes next to each item. When the box is checked, it adds it to a collection called checkedItems. When the Update button is pressed, it bring up a pop up with another gallery showing the checkedItems collection. Then, the user can put in a number to add to or take from the inventory. 

 

However, when multiple items are checked, the SharePoint List does not update any item after the first one. Below are some screenshots. 

 

**Before Patch

rknight_0-1614381809421.png

 

**Add Inventory button with code

rknight_1-1614381890358.png

 

**Updated List (now it's adding the same value to only 2 items instead of the specified value for each item)

rknight_2-1614381989632.png

 

Any thoughts would be greatly appreciated! Best wishes!

14 REPLIES 14

Unfortunately, neither of those worked. 

 

For the Update button, I am getting an error on the Value(_item.TextInput2_3.Text). It says the "Name isn't valid."

I think it has trouble using the variable with the text box input. 

 

For the gallery in the popup window, nothing is showing up at all any more. 

 

What I want to have happen is:

1) User selects from main gallery (Gallery2) that they want to change the quantity of in inventory. They do this by checking the boxes next to each item they want.

2) The User selects either Add or Take. This bring up the same popup window, but changes how the Update button behaves. This second gallery (Gallery7) shows them the color and length of the item they selected along with a textbox that they will enter a number into. This number will either increment or decrement the quantity of that specific item in the SharePoint list.

3) Once all info has been entered, the User hits the Update button, and it takes those values from the text boxes and increments or decrements the SharePoint list item's quantity by that number.

 

I hope that cleared up a bit the intention of each screen/gallery/button. Any thoughts?

 

P.S. Thank you so much for all of your help. 

RandyHayes
Super User
Super User

@rknight 

Happy to help...we'll get this going!

 

Couple of clarifications and understandings:

1) User selects from main gallery (Gallery2) that they want to change the quantity of in inventory. They do this by checking the boxes next to each item they want. What is the name of the checkbox in Gallery2?

2) The User selects either Add or Take. This bring up the same popup window, but changes how the Update button behaves. This second gallery (Gallery7) shows them the color and length of the item they selected along with a textbox that they will enter a number into. This number will either increment or decrement the quantity of that specific item in the SharePoint list. Got it.

3) Once all info has been entered, the User hits the Update button, and it takes those values from the text boxes and increments or decrements the SharePoint list item's quantity by that number. Got it.

 

So what is Gallery 2 and Gallery1_1??  Or were they interjected erroneously into this thread?

 

So to revise based on the above and further clarity,

Your PopUp gallery (Gallery7) - Set the Items property to the following:

ForAll(
    Filter(Gallery2.AllItems, yourCheckBoxControlNameInGallery2.Value) As _item,
        {ID: _item.ID,
         Length: _item.Length, 
         Color: _item.Color,
         Quantity: _item.Quantity
        }
    )
)

Replace yourCheckBoxControlNameInGallery2 with the name of the checkbox control in your main gallery.

Replace Length above with the proper column name for Length (if it is not Length).

Replace Color above with the proper column name for Color (if it is not Color).

 

In the PopUp Gallery (Gallery7), your Color Name Label would be set to : ThisItem.Color

Your length label should be set to ThisItem.Length

 

And your Update OnSelect action property should be:

Patch('Inventory Tracking - TESTING',
    ForAll(
        Filter(Gallery7.AllItems, !IsBlank(TextInput2_3.Text)) As _item,
        {ID: _item.ID,
         Quantity: _item.Quantity + 
            (Value(_item.TextInput2_3.Text) * If(_addPressed, 1, -1))
        }
    )
);
Set(_addPressed, false);
Set(_takePressed, false);
Set(_popup, false);
Set(isChecked, false);
Set(isChecked, true)

 

 

 

 

_____________________________________________________________________________________
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!

To answer your first question, the checkbox is called CheckBox2.

Gallery2 and 1_1 were the same thing. I think the name of it was just swapped around throughout all of the messages.

 

However, your formulas worked flawlessly. Again. You truly are a Super User! I cannot thank you enough for the help with this. You rock man.

RandyHayes
Super User
Super User

@rknight 

Perfect!!  I was only getting confused on all the names and the app flow.  We got to the bottom of it and I am glad it helped!!

You are quite welcome for the help...rock on!!

_____________________________________________________________________________________
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!
Matthewvize
Helper I
Helper I

Try putting value in front of the ID

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (3,077)