Hello,
I am trying to use the component in my application to show/hide parts of the blocks through client action or function check. To do so we need client action/function to check whether toggle is on or not, which is not available in the component. Even the "how to" document is also not accessible. Please suggest how to achieve toggle checking on client side.
Thanks,
Junaid
The recommended way to check whether a Toggle is ON or OFF on the client side is to bind it to a Boolean variable and use that variable in your screen logic. First, create a local Boolean variable, for example IsToggleOn, with the default value set to False.
Next, use the OnChange event of the Toggle to trigger a client action whenever the user switches it. Inside that client action, you can check the value of the Boolean variable. For example, if IsToggleOn is True, you can show Block A, otherwise show Block B.
To show or hide sections of the UI, you can also control the Visible property of blocks or containers directly. For instance, set BlockA.Visible = IsToggleOn and BlockB.Visible = Not(IsToggleOn).
Hello @Junaid Syed
You can achieve this using a data action approach
Since you need to know the toggle state on the client side, the best way is to fetch that state when the Screen or Block initializes.
In your Screen or Block, add a Data Action.
Inside that Data Action, call the Server Action provided by the Feature Toggle component (e.g., FeatureToggle_Check).
Assign the result to an Output Parameter of the Data Action (e.g., IsFeatureEnabled).
Use the DataAction.IsFeatureEnabled variable in the Visible property of your UI elements or within your Client Actions.
Hi,
Hope the below helps.
Create LocalIsOn : Boolean on the screen. Drop a Switch and set Variable = LocalIsOn; handle On Change if you need side-effects. Wrap the block you want to show/hide in a Container and set Visible = LocalIsOn (or Not(LocalIsOn) to hide on ON). This is the recommended “toggle → conditional UI” approach.
Saicharan