cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ward_1984
Frequent Visitor

Select a checkbox through the default tab. But the Oncheck tab doen't run

Hi,

 

I have made a app where i can filter and sort the dat in the gallery like you can see in the picture below.

 

Sorting.PNG

Now i want to save the setting for every user. And because there is some code after every checkbox which set a couple of vars, i thought of saving the value of the checkbox in the list. So i don't have to save all the different vars but only three statuses of the checkboxes.

 

I thought of selecting the checkbox by changing the default to there saved settings. This is no problem and the checkboxes take there saved values. But the code in the "Oncheck" and "Onuncheck" doens't run. 

Now my question, is this normal or should it run (what i thinks it should?).

And if not. Is there a way around it?

 

Thanks at advance.

Kind regards,

Ward

2 ACCEPTED SOLUTIONS

Accepted Solutions
v-xiaochen-msft
Community Support
Community Support

Hi @Ward_1984 ,

 

Thanks for your explanation. I understand what you mean.

 

Firstly, the Oncheck/Onuncheck property of the combo box control seems to be triggered by a mouse click on this control. 

 

We cannot trigger the Oncheck/Onuncheck property by setting the default property of the combo box control or using the Select() function.

 

So I suggest you write the formula in the property of the setting variable instead of in the Oncheck/Onuncheck property.

For example: If (varDefaultSortingDatum,******,******)

 

This may meet the same needs.

 

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

View solution in original post

I was afraid that was indeed the problem. 

I now put my code for Check and Uncheck in the "Onselect" tab and on the basis of which value the checkbox has (Self.Value) I run the right code.

 

It works on mouseclicks and if I want to change it through a var; I first change the value of the checkbox by the "Default" tab, like mentioned above. And then I use a Select(name of checkbox) for running the code. It simulate the same as a mouseclick..

 

Thanks for your input.

Kind regards,

Ward

View solution in original post

5 REPLIES 5
v-xiaochen-msft
Community Support
Community Support

Hi @Ward_1984 ,

 

When you select the check box control, the formula in the OnCheck property will be executed.

On the contrary, if you do not select the check box control, the formula in the OnUncheck property will be executed.

 

I did a simple test for you.

 

1\ Add a check box control and set its OnCheck property to:

Set(Thevar,"AAA")

 

Set the check box control's OnUncheck property to:

Set(Thevar,"BBB")

 

2\ Add a label control and set its Text property to:

Thevar

 

3\ The result is as follows:

2.PNG

2.PNG

If you are still confused, please provide a specific formula.

 

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

@v-xiaochen-msft thanks for the reply.

After reading my question again it was not that well written 😅. So will try to explain it a little better.

 

The code get run if i click on the checkbox and everything works fine. 
The problem lies when i want to check the checkbox by changing the value of a var. I send the value of this var to the "Default" tab of the checkbox. See picture. 

Default.PNG


So if i get my user settings where i stored the status of each checkbox that the  user has  saved. I write that status to (in this example) "varDefaultSortingDatum" and that works also. The checkbox will be checked if his value is true and unchecked at false. But the problem is that the code in the "Oncheck" or "Onunchecked" doen't run if i change the value through the "Default" tab.

I hope this is more understandable. 

Kind regards,

Ward

v-xiaochen-msft
Community Support
Community Support

Hi @Ward_1984 ,

 

Thanks for your explanation. I understand what you mean.

 

Firstly, the Oncheck/Onuncheck property of the combo box control seems to be triggered by a mouse click on this control. 

 

We cannot trigger the Oncheck/Onuncheck property by setting the default property of the combo box control or using the Select() function.

 

So I suggest you write the formula in the property of the setting variable instead of in the Oncheck/Onuncheck property.

For example: If (varDefaultSortingDatum,******,******)

 

This may meet the same needs.

 

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

I was afraid that was indeed the problem. 

I now put my code for Check and Uncheck in the "Onselect" tab and on the basis of which value the checkbox has (Self.Value) I run the right code.

 

It works on mouseclicks and if I want to change it through a var; I first change the value of the checkbox by the "Default" tab, like mentioned above. And then I use a Select(name of checkbox) for running the code. It simulate the same as a mouseclick..

 

Thanks for your input.

Kind regards,

Ward

@Ward_1984  I've found a better way.  Insert a toggle.  The OnCheck/UnCheck properties of a toggle don't require mouse input.  You can set the default property to the same as the checkbox.  And then set the OnCheck of the toggle to a variable.  This will select the item in the gallery. 

 

And if you don't like the toggle, just disable it and hide it and leave your checkbox the way it is.  The variable will still be set if the toggle is disabled and hidden.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (3,651)