web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Increment a Sharepoint...
Power Apps
Unanswered

Increment a Sharepoint list number by 1 when clicking a button

(1) ShareShare
ReportReport
Posted on by 88

Hi,

 

I have read other threads on this and it seems simple butyy I just cant get it to work 😞

My requirement is simple. I have connected a sharepoint list to the Powerapp which is called SPLIST, which contains two fields, name and QTY)

On the edit screen, I have added a button and tried to set the onselect value to Patch (SPLIST,SPLIST.QTY,{QTY:SPLIST.QTY+1}) but it doesnt like the syntax. I have tried all different ways to specify the source and records to be updated but I just cant seem to get it.

Sorry, I'm an absolute newb to Powerapps so Im sure its something really simple I'm doing wrong?

 

Thanks very much in advance for any help!

Categories:
I have the same question (0)
  • mdevaney Profile Picture
    29,989 Moderator on at

    @MikeWJS 

    Like this... Change the ID number to match the record you want to PATCH.

    Set(myRecord, LookUp(SPLIST, ID=1));
    Patch(SPLIST, myRecord,{QTY:myRecord.QTY+1}) 


    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • Community Power Platform Member Profile Picture
    on at

    Hi guy,

     

    I go try help you, lets go....

     

    If you trying create a new line on click  =  Patch(SPLISTS, Defaults(SPLISTS), {Title: "Clicked", Other Variable: 1}

    And if you try add on specif Line = Patch(SPLITS,  {ID : LineID}, { AddClicks : AddClicks + 1})

    i hope this helps

  • MikeWJS Profile Picture
    88 on at

    Thanks for the responses both!

     

    Sorry, I wasnt clearer.

    How the app will work is to click the new record button, then the edit form will load.

    The user enters the name of the record (e.g. Customers Name) and underneath it will be four different values, all defaulting to zero, with a button next to them so they can add one to the value each time they press the button (think picking a customers order, the button is pressed every time a product is added), hence I will not know the ID of the record to update, it is basically the current record.

    Hope this makes sense?

    Thanks again for taking the time to try and help me!

  • Community Power Platform Member Profile Picture
    on at

    Ok, lets do this...

     

    1 - On Screen going on "OnVisible" and put  = Set(num;1)

     

     

    image.png

     

    You finish set one variable when the Screen opens, 

     

    Now you need config the label and buttons

    Label Text = Variable

    On Label : Text = VariableOn Label : Text = Variable

     

    Buttons go update the values...

    On Button = put this functionOn Button = put this function

     

     

    When using a record that already exists in the variable you put = Set(num : ThisItem.NumProducts)

  • mdevaney Profile Picture
    29,989 Moderator on at

    @MikeWJS 

    My advice was not meant to hardcode a Product ID (example: 1).  It was meant for you to replace '1' with a dynamic reference to the ID you want to PATCH.

     

    Set(myRecord, LookUp(SPLIST, ID=your_product_id));
    Patch(SPLIST, myRecord,{QTY:myRecord.QTY+1}) 

     

    If you need more direction, this all I can give until you show how the 'add product' UI is being accomplished and provide any relevant code.

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up." 

  • MikeWJS Profile Picture
    88 on at

    Sorry both for being a total newb and being dumb!

     

    @Anonymous Thanks, that kind of worked but the num value is not reset when the form is opened so when you create a new record it retains the last number instead of resetting to zero 😞

     

    @mdevaney Im not sure how to to this, the ID would just be the current ID. I'll try to explain exactly what Im doing.

     

    Ive created the list with customer (name), apples (value) and oranges (value) - fig 1

    Created the app - fig 2

    Run the app - fig 3

    Create a new record - fig 4

    Enter the customer name in the box (1), then add two buttons to increment the existing zeros for the quantity of each - fig 5

     

    I basically do not know how to use the buttons to increment the figures next to them.

     

    Thanks and sorry again!

     

     

     

     

  • Community Power Platform Member Profile Picture
    on at

    hi @MikeWJS 

     

    In the Apples field, put "ThisItem.Apples (NameOfCollumn) + num"
    And the button, put UpdateContext ({num, +1})

    Remembering to set the variable (num) when opening the screen  : Set(num , 0)

    For reset values, use Reset(NameField);; Reset(Label);; Reset(TextInput)....

  • MikeWJS Profile Picture
    88 on at

    Once again, my sincerest apologies.

     

    When you say the apples field, you mean in the default property when clicking on the field yes?

    By name of the column you mean in sharepoint yes? If so the column is called apples so I have tried ThisItem.Apples (Apples) + num which gives the error invocation of unknown or unsupported function, see screenshot 1 of what I have done.

     

     

  • MikeWJS Profile Picture
    88 on at

    I have managed to use this method,

     

    1) Add the Set(varIncrement,1) to the OnStart method of the App

    2) Add Set(varIncrement, varIncrement + 1) to the BtnProceed OnSelect event

    3) Set the Default property of the Textbox to varIncrement

     

    With some success, however the Apples field always stays at the last number used instead of resetting to 0 each time the edit screen is opened, even though I have used set(num,0) in the onvisible box of the edit screen form.

     

    Any ideas? This is so close now 😞 

     

    Thanks again!

  • MikeWJS Profile Picture
    88 on at

    Hi Both,

     

    I eventually used the method directly above but used the updatecontext instead of the set on form open. No idea why the set on form open didnt work though..

     

    Thanks again.

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 793 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 333 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard