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, a distinguished professional, boasts an impressive track record as a Microsoft MVP, having achieved this prestigious recognition for the eighth consecutive year since 2015. With an extensive career spanning over 18 years, Adnan has honed his expertise in various domains, notably excelling in SharePoint, Microsoft 365, Microsoft Teams, the .Net Platform, and Microsoft BI. Presently, he holds the esteemed position of Senior Microsoft Consultant at Olive + Goose. Notably, Adnan served as the MCT Regional Lead for the Pakistan Chapter from 2012 to 2017, showcasing his leadership and commitment to fostering growth within the tech community. His journey in the realm of SharePoint spans 14 years, during which he has undertaken diverse projects involving both intranet and internet solutions for both private and government sectors. His impact has transcended geographical boundaries, leaving a mark on projects in the United States and the Gulf region, often collaborating with Fortune 500 companies. Beyond his roles, Adnan is a dedicated educator, sharing his insights and knowledge as a trainer. He also passionately advocates for technology, frequently engaging with the community through speaking engagements in various forums. His multifaceted contributions exemplify his dedication to the tech field and his role in driving its evolution.

Leave a Reply