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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Problems with UpdateCo...
Power Apps
Answered

Problems with UpdateContext + Button OnSelect to increase a DataCardValue by 1

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello all. 

 

I'm trying to use a button to update a DataCardValue in a "New" form inside my PowerApp but the UpdateContext function doesn't seem to be working for me like I've seen other people using it. I'm wanting to take whatever value exists currently in a given DataCardValue, and increase it by a count of 1 when the button is pressed. 

 

I've tried several variations on this:

 

UpdateContext({DataCardValue41: DataCardValue41.Text + 1}) 

 

I've tried leaving off the .Text with no success. Also, I've tried using the Sum function with another label titled PlusOne, so I'd end up with something like this: 

 

UpdateContext({DataCardValue41: Sum(DataCardValue41.Text, PlusOne.Text)})

 

I'm dealing with DataCardValues that are either empty or will have a 0 in them. I can do either, if I need to put 0's in as a default value then that's fine. 

 

Thanks in advance! 

 

 

updatecontext problem.png
Categories:
I have the same question (0)
  • Verified answer
    Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Hi @Anonymous,

     

    Try UpdateContext({var: DataCardValue41.Text+1}) on the button and put var as the default property of the datacardValue text box. 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Perfect! Thanks so much! Works like a charm. 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Here's another issue, though.. what if I have multiple buttons that I want to do this with? I can only use var for one it looks like. 

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Var could be anything. UpdateContext() could use webuildwoodscat instead of var in the expression. UpdateContext creates a variable that is extremely versatile it can be a formula, a value, a record in a table our when a table itself.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Gotcha. That does work, however it may have created another issue:

     

    Does using these variables as the default values in DataCardValue fields break the ability to use ResetForm function? Since I've started using variables in the DataCardValue fields of a Form, ResetForm() doesn't seem to be working anymore to clear those DataCardValue fields.

     

    Any thoughts on that? You've been very helpful so far, so thank you for that. 

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at
    You will need to reset the variables to "" using the UpdateContext({var:""})
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Drrickryp wrote:
    You will need to reset the variables to "" using the UpdateContext({var:""})

    Thanks! I tried to implement that for just one variable with OnSelect on a button, and got the following error:

     

    "Incompatible type. We can't evaulate your formula because the context variable types are incompatible with the types of values in other places in your app." 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 519 Most Valuable Professional

#2
11manish Profile Picture

11manish 489

#3
Haque Profile Picture

Haque 327

Last 30 days Overall leaderboard