Use hidden column value in another column without unhiding

Copper Contributor

Hello,

I have a list with a hidden column. I would like to use the value of the hidden column in another column but it does not work. I should make the column visible to use its value. Is there a way that I can work with the hidden column values without unhiding?

2 Replies

Hi @parham_6 ,

you mean using SharePoint List formatting? Then no... All columns you want to acccess from the JSON sheet must be included in the view.

You can kind of get arround that if you create a calculated column that contains the information from multiple columns. Then you can "parse" the value in your stylesheet.

So i.e. with a calulated column that concatenates the fields "Status" and "Value" using a "-"

=[Status]&"-"&[Value]

 you can use this sheet

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "div",
   "txtContent": "=substring(@currentField.displayValue,indexOf(@currentField.displayValue,'-')+1,indexOf(@currentField.displayValue + '^', '^'))",
  "style": {
    "background-color": "=if(substring(@currentField.displayValue,0,indexOf(@currentField.displayValue,'-')) == 'Committed','#FFA07A', '' )"
  }
}

to display the value but have the background color of the column formatted differently if the status is "Commited".

The formulas in the JSON Sheet might become very complicated for much more that 2 parameters, though.

Best Regards,
Sven

 

@parham_6 This is a known behavior in SharePoint. In order to format a column or view using JSON, the column you are referencing in JSON code must be included in the list view.

 

According to official documentation, You construct a JSON object that describes the elements that are displayed when a field is included in a list view, and the styles to be applied to those elements.

 

Try following workarounds and see if it works for you:

  1. Use the column you are trying to refer in JSON for filtering or sorting list view. The column will not be visible in list view but you can use it in JSON as it is used for filtering/sorting list view. Reference 
  2. Using calculated column: Column-Formatting With a Column not present in the view 

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.