cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate II
Advocate II

Need to be able to toggle back and forth visibility of questions based on answer being yes or no.

I have a field that has a toggle yes/no option.  That field defaults to yes.  With the default of yes,  there are several questions following that default to showing.   If they toggle the answer to no, the questions go away (are not visible). All of this is working just fine.

 

I want them to be able to toggle back and forth and the questions show or don't show based on the toggle.  After the initial choice of "no" is made and the questions go away, you can't toggle back to bring the questions back.  There has to be a way to do that doesn't there?  Any help would be appreciated. 

 

Current settings:

On the OnUncheck variable, I have UpdateContext({cursel:false})

Then on all of the subsequent fields I have Visible = cursel

 

What do I need to change/add to get the toggle back and forth to work? Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Need to be able to toggle back and forth visibility of questions based on answer being yes or no

Hi @Christy_Roach

 

I would suggest not setting the context variable during the onselect event of the toggle. Just access the value of the toggle directly.

 

If you use a toggle control, then you don't have to set a variable with the value as the toggle itself has a value of true or false. This can be referenced in the visible property of the other controls: Toggle1.Value. This will show the control if the Toggle is 'On' and hide it is it is 'Off'. If you want to show the control when the toggle is 'Off' and hide it when the toggle is 'On', you can use !Toggle.Value in the visible property of the controls.

 

 

View solution in original post

7 REPLIES 7
Highlighted
Super User
Super User

Re: Need to be able to toggle back and forth visibility of questions based on answer being yes or no

Hi @Christy_Roach,

 

Try to do the following with a button by putting the following in on the onselect.

UpdateContext({cursel:!cursel})

This will change the variable value from true to false and vice versa.

 

If you use a toggle control, then you don't have to set a variable with the value as the toggle itself has a value of true or false. This can be referenced in the visible property of the other controls: Toggle1.Value

 

Let me know if you don't come right.

 

 

 

Highlighted
Advocate II
Advocate II

Re: Need to be able to toggle back and forth visibility of questions based on answer being yes or no

Hi! Thanks so much! I've made the change to OnSelect to: UpdateContext({cursel:!cursel})

That's got the toggle working but it's backwards of what I want.  So close! How would I reverse it?

 

I'm pretty new to this and not sure what youj mean about the second part.  In the visible field for the other controls I have cursel.

 

 

Highlighted
Super User
Super User

Re: Need to be able to toggle back and forth visibility of questions based on answer being yes or no

Hi @Christy_Roach

 

To reverse it you can specify !cursel on the visible property. Tihs will inverse true and false, so if the cursel is true, !cursel will return false, and vice versa.

 

Let me know if you don't come right.

Community Support
Community Support

Re: Need to be able to toggle back and forth visibility of questions based on answer being yes or no

Hi @Christy_Roach,

Based on the needs that you mentioned, I think a global variable could achieve your needs.

I have made a test on my side, please take a try with the following workaround:5.JPG

 

6.JPG

 

7.JPG

Set the OnVisible property of the screen to following:

If(Toggle1.Value = true, Set(IsShow, true), Set(IsShow, false))

On your side, you should type:

If(Toggle1.Value = true, Set(cursel, true), Set(cursel, false))  /* <-- Toggle1 represents the Toggle control on your side */

Set the OnSelect property of the Toggle control to following:

If(Toggle1.Value=true, Set(IsShow, true), Set(IsShow, false))

On your side, you should type:

If(Toggle1.Value = true, Set(cursel, true), Set(cursel, false))  /* <-- Toggle1 represents the Toggle control on your side */

Set the Visible property of the Label control to following:

IsShow

On your side, you should set the Visible property of the subsequent fields to following:

cursel

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Advocate II
Advocate II

Re: Need to be able to toggle back and forth visibility of questions based on answer being yes or no

Its unfortunately, still backward.  It's displaying and removing the field toggling the opposite direction.  The first field "event name" hides with !cursel in the visible fields.  Would the OnSelect formula for the toggle still be UpdateContext({cursel:!cursel})?  See second picture.Screenshot2.png

screenshot1.png

 

 

Highlighted
Super User
Super User

Re: Need to be able to toggle back and forth visibility of questions based on answer being yes or no

Hi @Christy_Roach

 

I would suggest not setting the context variable during the onselect event of the toggle. Just access the value of the toggle directly.

 

If you use a toggle control, then you don't have to set a variable with the value as the toggle itself has a value of true or false. This can be referenced in the visible property of the other controls: Toggle1.Value. This will show the control if the Toggle is 'On' and hide it is it is 'Off'. If you want to show the control when the toggle is 'Off' and hide it when the toggle is 'On', you can use !Toggle.Value in the visible property of the controls.

 

 

View solution in original post

Highlighted
Advocate II
Advocate II

Re: Need to be able to toggle back and forth visibility of questions based on answer being yes or no

Perfect! Thanks! It's working!

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (4,663)