cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper I
Helper I

Update Checkbox Value OnSelect

New to PowerApps and working on a new solution.  I can't figure out how to do something that seems quite simple...

 

I need to update a checkbox control's value to true (i.e. "checked") when an icon is clicked.

In the Icon configuration, what formula do I need to enter into OnSelect?

 

I have tried using Set and UpdateContext, but I think those only work with variables.  This is updating the value of a control....

 

Checkbox1.Value=true

 

Appreciate the advice.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User II
Super User II

@Pegger 

Like this:

 

checkboxfromicon83945.gif

 

 

(Screen) Screen1 OnVisible:

Set(_CheckedExampleVariable,false)

 

(Checkbox) Checkbox1 Default:

_CheckedExampleVariable

 

(Icon) Star1 OnSelect:

Set(_CheckedExampleVariable,true);

 

 

 

View solution in original post

4 REPLIES 4
Super User II
Super User II

@Pegger 

Like this:

 

checkboxfromicon83945.gif

 

 

(Screen) Screen1 OnVisible:

Set(_CheckedExampleVariable,false)

 

(Checkbox) Checkbox1 Default:

_CheckedExampleVariable

 

(Icon) Star1 OnSelect:

Set(_CheckedExampleVariable,true);

 

 

 

View solution in original post

It worked.  I was hoping there was a way to do it without a variable, i.e. set it directly, only because I will have to establish 10-15 variables, but it is functional so thank you!

@Pegger 

 

If that exists we would be curious of it.

 

However, this type of attempt:

 

 

 

Checkbox1.Value=true

 

 

 

 

is actually antipattern in the thinking for Power Apps right now, and it is something that is not possible at all in any way we know of currently. If someone else from this forum disagrees, we would be curious to know what is the alternate way to do it with the Checkbox1.Value=true kind of way. To our understanding, the only way is the way we gave. It can be a "context variable" instead of a whole variable if it is guaranteed that all the operations will take place on the same screen only (in our example, those are variables that can work from any screen, and not context variables scoped to one screen) - that is about the only thing we believe could be done to slightly improve on it is make them context variables if you are absolutely sure they would be on one screen - but if you ever use it from other screen, e.g. if the Icon is clicked from a screen other than the one the checkbox is present on, then it must be a variable just like in our example.

 

Regarding:


@Pegger wrote:

It worked.  I was hoping there was a way to do it without a variable, i.e. set it directly, only because I will have to establish 10-15 variables, but it is functional so thank you!


 

Another way to use "one thing" instead of "multiple things" could be an inline Collection with multiple Columns on the first Record of the same Collection, and this can be accessed from any Screen as well - but this is less straightforward to use than just the Variable of our simple example -  and you would want to be careful, we would not really recommend it. It is even trickier if you use multiple Collection Records instead of a Collection with just one Record and multiple Columns. We recommend instead to just use multiple variables as it is probably more straightforward that way. We just wanted to mention it in case you would find this way with the Collection interesting as well.

I trust your experience over mine!  But surely would be curious if there is another way.  Regardless, you have helped me get past the next hurdle.  Thanks again!

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (25,630)