function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Craig WoodmanCraig Woodman 

Flow Screen Toggle Button - Winter 20 - Component Visibility

I have run into a problem with component visibility using the toggle button feature in flow screen components.  When using the native Salesforce toggle button, I cannot set the visibility components based on the value of the toggle button.

I have established a toggle button titled togShowHide.  I have set a component visibility based on the following:

User-added imageThe problem is, the toggle does not do anything when activated or deactivated to change this component visability - and the visibility is always OFF.

When I reversed everything, making the toggle button active (true) by default, and setting components to display when the value was true, the components will display.  

What it looks like to me, is that the flow components will only allow you to filter the visibility by a variable or other resource that is TRUE.  It just doesn't work with a false value.  In fact, the component won't display at all.

HOWEVER, when I do the same actions using a checkbox, I can filter a flow screen component to display either on a TRUE value or a FALSE value.

Is this a bug, or normal behavior for the toggle component?
Best Answer chosen by Craig Woodman
Evan PonterEvan Ponter
I discovered a workaround for this after pondering if a False value is being used in the toggle, or perhaps an empty string, or a null value. The "Set Component Visibility" criteria lets you specify any resource in the "Resource" field, and only a subset of resource types in the "Value" field. So I created a constant using the text data type and set the value to {!$GlobalConstant.EmptyString}.
Constant set to an empty string
I set this EmptyString resource in the "Resource" field under the Set Component Visibility section for the component that I wanted to display when the toggle is set to False. Then I used the Equals operator. Then I specified the toggle's value attribute in the "Value" field.
Set Component Visibility settings

Now my toggle will show my field when it is set to a false value, and hide it when it's set to a true value.
Toggle set to False shows the desired field
Hope this helps!!
-Evan

All Answers

Evan PonterEvan Ponter
I discovered a workaround for this after pondering if a False value is being used in the toggle, or perhaps an empty string, or a null value. The "Set Component Visibility" criteria lets you specify any resource in the "Resource" field, and only a subset of resource types in the "Value" field. So I created a constant using the text data type and set the value to {!$GlobalConstant.EmptyString}.
Constant set to an empty string
I set this EmptyString resource in the "Resource" field under the Set Component Visibility section for the component that I wanted to display when the toggle is set to False. Then I used the Equals operator. Then I specified the toggle's value attribute in the "Value" field.
Set Component Visibility settings

Now my toggle will show my field when it is set to a false value, and hide it when it's set to a true value.
Toggle set to False shows the desired field
Hope this helps!!
-Evan
This was selected as the best answer
Marko Atanackovic 18Marko Atanackovic 18
Hi, 
this video helped me a lot. Hope it can help you too.
https://www.youtube.com/watch?v=60s0Mn4lBkA
Ben Renko 5Ben Renko 5
Evan,
Was wondering if you would share the settings for your Toggle?
Evan PonterEvan Ponter
Yes - here are the settings for the toggle component:
Toggle Settings
The "Value" is set to the value attribute of this same toggle component. That way it "remembers" what the user selected if they move on to a different screen and click "previous" to come back to this screen.
Isaac Duke 2Isaac Duke 2
I was having the same issue, but then I saved the flow and the toggle screen compenent showed up in the visibility dropdown. Not sure if that was the exact reason or something else happened, but you shouldn't have to do this workaround described above
Scott Nelson SolutionistScott Nelson Solutionist
An additional quirk I found thanks to this thread. I followed much of the good advice above and was still having the issue where the toggle component was not an option for the criteria. Then I stumbled across this:
Any screen input component with Manually assign variables (advanced) selected isn’t available as a resource for conditional visibility on the same flow screen. (Flow Conditional Visibility Consideration (https://help.salesforce.com/articleView?id=flow_considerations_design_conditional_visibility.htm&type=0" target="_blank))
It seems that once Manually assign variables has been selected for one component, it becomes the default for new ones. I unchecked the Manually assign and was then able to use the toggle as shown in the video referenced early in this thread.

 
Craig WoodmanCraig Woodman
Scott, That was very helpful!  I ran into that as well!  
Kenny Barry 6Kenny Barry 6
I was not able to use the EmptyString hack above to address this requirement.  I was successful, however, adding conditional visibility criteria for Toggle = null (by leaving the value blank).  I hope this is useful for others.
John ShaulJohn Shaul
That video is private