Forum Discussion
eenochs-turner
May 05, 2020Brass Contributor
JSON Statement Help
I have a JSON statement that I'm getting an error on. Error is JSON Statement {
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType...
Vikram_Samal
May 06, 2020MCT
eenochs-turner In the below code i could see two things which might need to be corrected
"color": "if=([$EMR_x0020_Effective_x0020_Date] == ' ' && [$EMR_x0020_Effective_x0020_Date] +31556952000 <= @now, '#ff0000', '#000000')"- Your are using && operator instead of ||
- You are trying to set color for a text which is blank which will never happen
If you want to achieve something like this I will write something like this:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"attributes": {
"class": "=if(toString([$Date]) =='','sp-field-severity--severeWarning',if([$Date] <= @now-31556952000,'sp-field-severity--severeWarning', ''))"
},
"children": [
{
"elmType": "span",
"style": {
"display": "inline-block",
"padding": "0 4px"
}
},
{
"elmType": "span",
"txtContent": "@currentField"
}
]
}Hope this helps!