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 / Set checkbox value pro...
Power Apps
Answered

Set checkbox value programatically

(2) ShareShare
ReportReport
Posted on by 24

The question I'd like to ask here is actually very simple.  So I'll put the question first and just in case the full context is underneath it.  Thanks!

 

THE QUESTION:

I want to set a checkbox value from the OnSelect of a button.  I thought I could do it by entering the following to the OnSelect formula of the button:

 

cbx_AssignedToMe.Value = false

 

Entering this formula does not result in any error.  But, alas, life is not this simple and when I press the button nothing happens.

 

I've searched around and this question always seems to get answered by explaining about the default value.  But I don't think that applies to my scenario.  I want to clear the checkbox programatically.  How can I do it?


THE CONTEXT:
I have built a filter screen with a bunch of different data filters that can be set.  On this screen are two checkboxes which act as simple helpers to set up two of the filters to the current user.  In the grab below, you can see that because I set the "Assigned to me" checkbox, the associated Assigned to: textbox got disabled and the user was automatically assigned to me.

bh4017_1-1624898760510.png

 

 

At the bottom of the screen I have a clear filters button which has the job of resetting all the filters.  As part of this, I want to clear the checkboxes back to false.


The filters themselves are easy to clear as I have them set up as variables and I can just use the Set(variable, value) method to do it.  This does result in all my filters being cleared.  But unfortunatley the checkboxes (if checked) stay checked and I need to clear them programatically.

 

 

Categories:
I have the same question (0)
  • Verified answer
    TheRobRush Profile Picture
    11,128 Moderator on at

    This is an example that will show you how to do this, not coded for your exact situation.

    In my example a single button sets both check and uncheck status, in yours you can split this between two buttons.

     

    Code for onselect of the button is.

    If(checkVar=true,
     Set(checkVar,false),
     Set(checkVar,true))

     

    Then you set the Default code of your checkbox to

     

    checkVar

     

    as checkVar is cycled between true and false by onselects the checkbox will check and uncheck itself

  • bh4017 Profile Picture
    24 on at

    Thank you - I was able to adapt your solution to suit my scenario.  In my scenario I am only concerned with clearing the checkbox via a button, never checking them.  So the approach is different but the basis of your solution is sound and I've got it working.

     

    It does seem like a total 'round the houses' way to do something that I feel should be very simple.  I think I should be able to assign the checkbox value directly.

     

    But there you go, it is what it is and it's working - thanks again.

  • intherightplace Profile Picture
    30 on at

    It's (more than) a little late now but this should work for setting off if it's on...

    If(cbx_AssignedToMe.Value, Select(cbx_AssignedToMe));

     

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 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard