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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (3,186)