Feb 09 2023 12:44 PM
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?
Feb 09 2023 10:55 PM
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
Feb 10 2023 01:18 AM
@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:
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.