SOLVED

Show/Hide Field with conditional formula or column formatting not working

Brass Contributor

Hi All,

 

I have a list that includes two columns.

 

  • Failure Reason - (drop down choice)
  • Comments - (single line text)

 

The goal is to have the Comments field/column remain hidden unless the choice "Unknown" is selected in Failure Reason.

 

In the Comments column, I have tried entering the following formula in the Column Formatting with no success. 

 

{
 "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
 "elmType": "div",
 "txtContent": "=if([$Failure_x0020_Reason] == 'Unknown', 'Comments: ', '')",
 "children": [
   {
     "elmType": "div",
     "style": {
       "display": "=if([$Failure_x0020_Reason] == 'Unknown', 'block', 'none')"
     },
     "children": [
       {
         "elmType": "span",
         "txtContent": "[$Comments]"
       }
     ]
   }
 ]
}

 

 

I have tried using the following formula in the Edit Conditional Formatting field with no success. 

 

=if([$$Failure_x0020_Reason]=='Unknown', 'true', 'false')

 

 

SharePoint accepts the formula but when I refresh and test, the Comments field remains despite what is selected. When I researched into it further, I read that conditional formulas do not work with choice with multiple selections columns.

 

As a work around, I created a new Column called Unknown (intended to be hidden) and only have it populate with "Unknown" if the Failure Reason is unknown. Then I tried to run the formula in the Comments field based on that column. Still doesn't work, the Comments field remains despite choice selected.

 

I just want the comments field to appear only when someone picks "Unknown" in the Failure Reason field. I can't believe this is so incredibly difficult to achieve. Can someone please help me figure out what I'm doing wrong? This is infuriating! I would greatly appreciate ANY HELP!

1 Reply
best response confirmed by normabeez (Brass Contributor)
Solution

@normabeez 

If you are trying to hide the comments field from list form based on single selection choice column values, you can use the conditional formula in this format: 

 

=if([$ChoiceColumnInternalName]=='Unknown', 'true', 'false')

 

Where [$ChoiceColumnInternalName] is an internal name of your column in SharePoint list in this format: [$InternalNameOfColumn]. You can get the internal name of your SharePoint list columns by following this article: How to find the Internal name of columns in SharePoint Online?

 

You have to use only once before column name in the conditional formula.

 

DocumentationShow 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.

1 best response

Accepted Solutions
best response confirmed by normabeez (Brass Contributor)
Solution

@normabeez 

If you are trying to hide the comments field from list form based on single selection choice column values, you can use the conditional formula in this format: 

 

=if([$ChoiceColumnInternalName]=='Unknown', 'true', 'false')

 

Where [$ChoiceColumnInternalName] is an internal name of your column in SharePoint list in this format: [$InternalNameOfColumn]. You can get the internal name of your SharePoint list columns by following this article: How to find the Internal name of columns in SharePoint Online?

 

You have to use only once before column name in the conditional formula.

 

DocumentationShow 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.

View solution in original post