JSON does not hide choice options correctly in a SharePoint online list

Peter N 0 Reputation points
2023-08-23T09:43:49.44+00:00

I've a Choice column in a SharePoint online list. The column contains 19 values, of which the first 6 are still active. The values that are deprecated cannot be deleted. As text and script editor web parts are blocked in my environment, I want to hide every choice but the first 6:

Culture & Empowerment, Gigabit Network, Digital Ecosystems, Society & Sustainability, Customer Experience, Grow Profitability.

The JSON code I use seems correct to me, but it's buggy: 2 choices are not visible, some choices suddenly show twice in the list and some of the deprectated items are shown.

This is the code I used:

{

"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",

"elmType": "div",

"attributes": {

"class": "sp-field-custom-format"

},

"children": [

{

"elmType": "span",

"txtContent": "[$Theme]"

}

],

"style": {

"display": "=if@currentField == 'Culture & Empowerment' || @currentField == 'Gigabit network' || @currentField == 'Digital Ecosystems' || @currentField == 'Society & Sustainability' || @currentField == 'Customer Experience' || @currentField == 'Grow Profitability', 'block, 'none')"

}

}

Can anyone help me out?

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
11,230 questions
{count} votes

1 answer

Sort by: Most helpful
  1. PacoCN 15 Reputation points
    2024-02-03T08:30:01.3066667+00:00

    Dear expert I found a issue when setting format in SharePoint List via Json Error: ref '/properties/attributes/class' in 'https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json' can not be resolved.(768) The URL is correct, but why there is an error?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.