Forum Discussion
View Formatter not working with Custom Colors
I love the fact we can format rows now so naturally I take it for a spin and it doesn't work right? Does anyone have any idea where I'm going wrong? I've also tried using words like 'blue' instead and still nothing.
If I use the code from Microsoft's site it works using the following JSON:
{
"schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
"additionalRowClass": "=if([$Category] == 'Cleaning', 'sp-field-severity--good', if([$Category] == 'Subcontracting', 'sp-field-severity--low' ,if([$Category] == 'Admin and Support','sp-field-severity--warning', if([$Category] == 'Parts and Equipment','sp-field-severity--blocked', ''))))"
}
But I want to use HEX colors and none of the colors I'm selecting are working. I replaced the 'sp-field-severity--good' with '#818A8F' and it doesn't take. In addition, I tried using this code instead and it also doesn't work:
{ "schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
"additionalrowClass": {
"style": {
"font-weight": "bold",
"background-color": {
"operator": "?",
"operands": [
{
"operator": "==",
"operands": [
"[$Category]",
"Cleaning"
]
},
"#818A8F",
{
"operator": "?",
"operands": [
{
"operator": "==",
"operands": [
"[$Category]",
"Subcontracting"
]
},
"#08395B",
{
"operator": "?",
"operands": [
{
"operator": "==",
"operands": [
"[$Category]",
"Admin and Support"
]
},
"#B1BA36",
{
"operator": "?",
"operands": [
{
"operator": "==",
"operands": [
"[$Category]",
"Parts and Equipment"
]
},
"#A5242B",
{
"operator": "?",
"operands": [
{
"operator": "==",
"operands": [
"[$Category]",
"Workwear"
]
},
"#FFC613",
{
"operator": "?",
"operands": [
{
"operator": "==",
"operands": [
"[$Category]",
"Fleet"
]
},
"#E37919",
"#FFFFFF"
]
}
]
}
]
}
]
}
]
}
]
},
"color": "WHITE",
"padding-left": "10px"
}
}
}