This is about JSON formatted views (not columns) in modern SharePoint online.
List A has a Yes/No field. The values show as Yes or No in the view. When I format the view and show the field value using "txtContent": "[$MyField]"
, it shows as true
or false
. (the screenshot has two of these side by side, several records)
In order to conditionally format the elements, I can use the field on its own, since it evaluates to True or False. No operator required.
"class": "=if([$MyField],'sp-field-severity--good','sp-field-severity--blocked')"
List B also has a Yes/No field. The values show as Yes or No in the view. When I format the view and show the field value using "txtContent": "[$MyYesNoField]"
, it shows as Yes
or No
.
In order to conditionally format the elements, I have to use a comparison operator and compare with Yes or No as text strings:
"class": "=if([$MyYesNoField]=='Yes','sp-field-severity--good','sp-field-severity--blocked')"
What causes the difference between these two columns in the two different lists and how can it be influenced?
When I download the lists to Excel, the columns all show True/False.
Both lists are populate with a Flow that sets the column values to True/False, not Yes/No.
The problem is that a condition in JSON that is based on the value of the yes/no field will work fine if it is a true/false value, but the view will not render correctly in a list web part when the value is Yes/No and the condition needs to compare with text.
Therefore, I need the Yes/No column to internally store the values as TRUE/FALSE, not as Yes/No.
Any ideas?