cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rlbstein
New Member

Subtracting Two Values and Updating Sharepoint List Column

I have about 15 hours into the app I am creating for work and 13 of those are trying to figure this out.

 

Basically, my app tracks tool inventory at my job. Put in your email address on the welcome screen and the start shopping button appears. It then navigates to a browsegallery that gets its info from a SharePoint list. When you select and item, it goes to a detail page to show a pic of the item, how many are on hand, and other pertinent info. Once selecting the shopping cart button, it sends the item to both a collection called ShoppingCart and another screen that shows all items you placed in the shopping cart. 

 

Once you are done shopping, you click the order button and it creates another collection called Too Receipt List in SP and writes the info I want a record of. It sends an email of the items to the person that originally put their email on the welcome screen and navigates to a success screen and after a five second timer, returns to welcome screen.

 

All of that works perfectly. What I cannot figure out is how to patch, update, forall, first, filter, and every other command you can think of to perform a simple subtraction of "1" from all items in the Gallery on the shopping cart page, to that record on the main SharePoint tool list. I say "1" because I we only give out one of each tool to the employees so no need to have it do any more. 

 

Here is what I have and I have modified this so many times, I know it is wrong but may clue someone in as to what I am doing wrong. Oh, and at one time in hours I have researched this issue, I was able to see it deduct one time from only one record even though there were multiple in the shopping cart. Don't remember what I used to do that now.

 

ForAll(Gallery1.AllItems, Patch('Tool List for App', {ItemQuantitySP: Value(ItemsOnHand.Text) - Value(Slider1.Value)}));

 

Slider1 is a hidden slider that is defaulted to only have a value of "1". I have also done this without the value(slider1.value) and just had "-1".

Also did this without the "forall", tried with "lookup", you name it. My brain is fried with what will most likely be a super fix.

1 REPLY 1
Eelman
Super User
Super User

@rlbstein 

You need to let the Patch statement know which record to adjust, currently you are not doing that. You can use 'As' or 'ThisRecord' to do this. If ItemsOnHand is a field in your 'Tool List for App' then you can do this:

 

ForAll(
    Gallery1.AllItems, 
       Patch(
         'Tool List for App',
         ThisRecord,
        {ItemQuantitySP: ThisRecord.ItemsOnHand - 1}
        )
);

 

 

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.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

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.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (4,269)