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

Edit gallery variable

I have a gallery which Ive created a variable from a ThisItem

Set(varQuantity, ThisItem.Quantity)

Then I have called the variable in a textlabel

varQuantity

I am trying to edit varQuantity on + and - buttons

UpdateContext({varQuantity: varQuantity-1})
UpdateContext({varQuantity: varQuantity+1})

for some reason its not working and its setting a new variable and wont recognise the one I have set and am trying to call

Could someone help me, is UpdateContext the wrong thing to use?

Kind regards
Ryan

1 ACCEPTED SOLUTION

Accepted Solutions
shoog
Dual Super User
Dual Super User

I would expect a field called quantity to be a number already.

You can check what type it is and optionally convert to a number by using the Value function.

Also, if the field can be empty, you should add some logic to handle that situation.

View solution in original post

5 REPLIES 5
shoog
Dual Super User
Dual Super User

Set is used for global variables, UpdateContext for local variables.

If you use Set again, it should work as expected.

hi @shoog ,

Thank you , Now I am getting this error

OiBigRed_0-1661023155677.png


Do I need to define it as a number when its set, and then call it as a number>

If so, How do I do that?

Kind regards
Ryan

shoog
Dual Super User
Dual Super User

I would expect a field called quantity to be a number already.

You can check what type it is and optionally convert to a number by using the Value function.

Also, if the field can be empty, you should add some logic to handle that situation.

thank you thats enabled it to work, youre right my SP list quantity wasnt set to number...

Works now locally but doesnt send the data back to the SP list now

How would I do this?

Kind regards 
Ryan

shoog
Dual Super User
Dual Super User

In the update property of the datacard (or in your patch function if you use that), you will have to convert the number back to the original datatype.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (4,454)