Forum Discussion

Vdraper's avatar
Vdraper
Copper Contributor
Sep 04, 2023

How to make a form field appear when a toggle button is turned on

Hi, I am very new to form building and not very technical so please bear with me.

 

I am trying to get a field to only be visible when the toggle button is turned on. 

How would I go about achieving this? 

  • Rob_Elliott's avatar
    Rob_Elliott
    Bronze Contributor

    Vdraper you will need to use a customized form with Power Apps for this.

     

    1.  In your SharePoint list click Integrate then Power Apps then Customize forms:

     

     

    2. Power Apps will open with your form displayed. On the Insert menu select Toggle:

     

     

    3. The toggle will be added. In the simple example below I've made the Department datacard bigger and dragged the toggle into an appropriate position. From the Advanced tab on the format panel I've also changed the False Text and True Text:

     

     

    4. Select the field you want to make hidden or visible dependiing on the toggle value. In the property field at the top left above Tree View select Visible from the dropdown and in the formula field type If(Toggle1.Value=true,true,false)

     

    Save and p[ublish your form back to SharePoint from the icons in the very top right of Power Apps and then go back to the list. If you make changes to your form you will probably find you need to refresh your screen several times to see the changes due to the caching that goes on. But when you open an item in the list, when you click the toggle the (in this case) the department field will be displayed; click the toggle again and it will be hidden.

     

    Rob
    Los Gallardos
    Microsoft Power Automate Community Super User.
    Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver)

     

  • Vdraper You can also achieve this using SharePoint out of the box capabilities (without using Power Apps forms). Follow below steps:

    1. Create Yes/No (boolean) type column in list for showing toggle
    2. Format the display of yes/no column using JSON column formatting using JSON samples provided in my answer at: Adding a clickable button to A SharePoint list to update a Yes/No Field - this will turn display of your Yes/No column from default checkbox to toggle
    3. Then you can show/hide list form fields using SharePoint conditional formulas. For example, you can use formula like: 

     

    =if([$YesNoColumnInternalName]==true,'true','false')​

     

    Where YesNoColumnInternalName is the internal name of your Yes/No column. You can get the internal name of your columns by following this article: How to find the Internal name of columns in SharePoint Online? 

     

    Follow this Microsoft official documentation for steps showing where to add the conditional formulas: Show or hide columns in a SharePoint list or library form 


    Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

Resources