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 / Problems with UpdateCo...
Power Apps
Unanswered

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

(0) ShareShare
ReportReport
Posted on by

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! 

 

 

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
    on at

    Perfect! Thanks so much! Works like a charm. 

  • Community Power Platform Member Profile Picture
    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
    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
    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

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