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!
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.
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!
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.
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)....
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!
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."
Ok, lets do this...
1 - On Screen going on "OnVisible" and put = Set(num;1)
You finish set one variable when the Screen opens,
Now you need config the label and buttons
Label Text = Variable
On Label : Text = Variable
Buttons go update the values...
On Button = put this function
When using a record that already exists in the variable you put = Set(num : ThisItem.NumProducts)
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!
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
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."
WarrenBelz
146,524
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,906
Most Valuable Professional