Requirement: Show or Hide a field based on another field’s value in SharePoint Online list form.
How to Show or Hide a Field based on Another Field in SharePoint Online?
In the past, we used to achieve this using jQuery Show or Hide SharePoint List Form Fields based on Another Field’s Value using jQuery. Now in SharePoint Online, we have Conditional Formulas Out of the box to achieve that functionality. Here is what we wanted: Show the “Project Classification” field only when the “Project Status” field value is set to “Yes”. Otherwise, hide it in the list Form. Here is how to configure conditional formula to show/hide columns based on other columns:
- Go to your SharePoint Online list >> Open the New Item form by clicking on the “New” button in your list.
- On the New item page, click on “Edit Form” button and then “Edit Columns” as in the below screen.
- Now, on the “Edit Columns” form, click on the three dots (:) and choose “Edit Conditional formula” from the menu. In my case, it’s the “Project Classification” field I want to show or hide.
- In the conditional formula, Enter the formula to show and hide the field. In my case, I have entered “=if([$IsActive] == true, ‘true’, ‘false’)” and hit save to commit your changes. Be sure you are using Internal Names of the columns, instead of display name.
- Now, the “Project Classification” field will be visible only when the “IsActive” field value is set to True!
The conditional formula must start with the “=” symbol followed by an “IF” condition. If the condition is satisfied, it returns true and that shows the field, else it returns false and hides the field.
Please note, not all columns are supported in conditional formulas as of today. E.g. Managed Metadata column, Person or group/choice with Multiple selections enabled, Currency columns, Location, Calculated columns, etc. are under the “Unsupported” list. Also, on columns marked as “Required”, we can’t apply conditional formulas to show or hide (that’s obvious, isn’t it?). Here are some examples:
|Column Type||Formula Example|
|Yes/No (check box) – Boolean||=if([$ProjectStatus]==’completed’,’true’, ‘false’)|
|Column with calculation||=if([$Column1]+[$Column2]<5000,’true’,’false’)|
More on conditional formulas in SharePoint Online List forms: https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/list-form-conditional-show-hide