May 05 2020 06:49 AM
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": "div",
"debugMode": true,
"txtContent": "@currentField",
"style": {
"color": "if=([$EMR_x0020_Effective_x0020_Date] == ' ' && [$EMR_x0020_Effective_x0020_Date] +31556952000 <= @now, '#ff0000', '#000000')"
}
}
I'm trying to look at one column and if the EMR Effective Date is less than the date + a year or if the entry is blank the text will be red. Error has to be in the statement but not sure where it is at.
May 06 2020 10:27 AM
@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')"
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!