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 / icon sets data card value
Power Apps
Answered

icon sets data card value

(0) ShareShare
ReportReport
Posted on by 987

does anyone know how to set the OnSelect of an icon (from insert >>icons) so that it sets the value of a data card value to a specific text value when pressed?

i tried : DataCardValue10.Value = "new value text"

but that throws an error

thank you for your help

audrie

Categories:
I have the same question (0)
  • Verified answer
    Brian Dang Profile Picture
    3,976 on at

    You will need to use the Reset property of the DataCardValue object. A "true" value in the Reset property will cause the object to revert to whatever you set as the Default property.

     

     

    icon1.OnSelect:
    
    UpdateContext({resetvalue: !resetvalue});
    UpdateContext({resetvalue: !resetvalue});
    UpdateContext({newvaluetext: [whatever value you want]})

     

     

     

    DataCardValue10.Reset:
    
    resetvalue
    DataCardValue10.Default:
    
    newvaluetext

     

     

    In PowerApps, you cannot directly use one object to tell an object to do something. UpdateContext allows you to create and store variables which you can use anywhere else on the screen. So one object will create newvaluetext, which another object will listen to indirectly.

     

    The reason you need resetvalue twice in icon1 is because it triggers true to achieve what it needs, then goes back to false so it's ready to trigger again when needed.

     

     

  • audrieFCT Profile Picture
    987 on at

    You're AWESOME!!

    {How about a mind meld?) Smiley Happy Heart

     

    It will take me a while to get used to the idea of Context versus Set Value methodologies....but I understand.

  • audrieFCT Profile Picture
    987 on at

    I encountered a problem with this approach. It works wonderfully when the edit form is for New Items, but unfortunately it prevents an existing value from showing up in edit mode. Would you know how to resolve that scenario?

     

    Thank you again!

  • Brian Dang Profile Picture
    3,976 on at

    This is where things get complicated.

     

    There are three Default properties to be aware of: 

    • Form#.Items
    • DataCard#.Default
    • DataCardValue#.Default

     

    When you use NewForm, the Form#.Items property is blank and that will trickle down to DataCard.Default and DataCardValue.Default, if they have not been changed from Parent.Default.

     

    If you use ResetForm, the Form#Items property will be in effect. If DataCard.Default and DataCardValue.Default are still set to Parent.Default, then they will take on the corresponding column for that record.

     

    I think as long as you made the edits to DataCardValue and not the other two, things should work out.

     

    Otherwise, you may need to use a variable to detect whether you are in New mode or Edit mode.

    And then based on the state of the variable, determine the default value. 

     

    For every instance of:
    
    NewForm(Form1)
    or
    ResetForm(Form1)
    
    accompany it with: 
    
    UpdateContext({edit: true/false})
    
    
    So you end up with: 
    NewForm(Form1);
    UpdateContext({edit: false})
    
    and
    ResetForm(Form1);
    UpdateContext({edit: true})
    and adjust DataCardValue.Default to:
    
    If(edit,Parent.Default,[your variable here])

    This means, if you're editing an existing record, it will take on the value of the existing record. Otherwise, it will take the value of clicking your icon. From here, you'll need to tweak the condition to suit your needs--if a condition is needed.

     

     

  • audrieFCT Profile Picture
    987 on at

    I'm going to try and see if I can do this.

     

    Related question: Can I have a different New Form than Edit Form instead of having them together on one?

     

    Thank you again!

  • Brian Dang Profile Picture
    3,976 on at

    You can have Form1 and Form2 both tied to the same datasource. 

     

    You can have all instances of Form1 as:

    NewForm(Form1)

    and all instances of Form2 as:

    ResetForm(Form2)

    I don't see a conflict here. It should work if you want to avoid the confusion of Default properties.

  • audrieFCT Profile Picture
    987 on at

    So I got the form working again, but now the icons aren't working. Apparently I'm not quite understanding how to 'add' the feature without impacting others. I'm rereading and trying again. Thank you for your comments.

  • cmatotek Profile Picture
    2 on at

    Is it possible to have a form or data table with a list of items that you can change the quantity of with a plus or minus icon? For instance, a grocery list.

    Apples _______
    Bananas _______
    Mangos _______

    - +

    The plus and minus icons would increase or decrease based on the filled selected.

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!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 834

#2
Valantis Profile Picture

Valantis 533

#3
Haque Profile Picture

Haque 410

Last 30 days Overall leaderboard