In this blog post I am going to show you that to show or hide fields on a list form based on the valued from other columns using JSON formatting. JSON is a very powerful way of formatting a SharePoint list/library form where you can also apply conditional formatting based on selected values in a list form on the run time. Follow my blog post on formatting details on SharePoint list forms for more details.

Scenario

I have a custom Patient info list which is used to takes the patient information. There are two column Patient History and History Details. Patient History is Boolean field and if its yes then show the History Details field, otherwise History Detail field should not be visible.

Implementation

Select any list item / document from the SharePoint list or library and expand the Edit Form button click on the Edit Columns.

This will show you complete list of Columns from the list, you can hide few columns form here and can change the order of the columns. Click on the three dots next column name and select Edit conditional formula.

A dialog will be opened, now you need to enter a formula to hide the field if Medical History option is selected.

=if([$MedicalHistory] == true, 'true', 'false')

Here I am applying the formula on a Boolean field, you can change the formula based on field type. And you can add multiple formulas based on your business need. Now on my form, when I am adding or editing a list item, the History detail field is not showing if the medical history field is not selected.

Adnan is six time Microsoft MVP (Since 2015) with over 16 years of extensive experience with major expertise on SharePoint, SharePoint based development, Microsoft 365, Microsoft Teams, .Net Platform and Microsoft BI. He is currently working Sr Microsoft Consultant at Olive + Goose. He is MCT Regional Lead for Pakistan Chapter since 2012. He is working on SharePoint for past 12 years and worked on different intranet/intranet solutions for private & govt. sector majorly in United states and Gulf region and have experience of working with multiple Fortune 500 companies. He is a trainer, technology evangelist and also speaks in community forums.

Leave a Reply