i have a list with a Deadline date field, i want to add a DaysToDeadLine field to show how many days are left before the DL. I read that there's issues with the today() function in sharepoint so i'm using the json formatting options, it works for giving me the days but it doesn't work the formatting option.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"debugMode": true,
"txtContent": "=floor((Number([$DeadLine])-Number(@now))/(1000*60*60*24))",
"attributes": {
"class": "=if(@currentField > 51, 'sp-field-severity--good', if(@currentField <= 50 && @currentField >= 11, 'sp-field-severity--warning', if(@currentField < 10, 'sp-field-severity--severeWarning', '')) + ' ms-fontColor-neutralSecondary'"
}
}
I'd like to make a conditional check:
- red background if the result of the calculus it's <10
- orange background if the result is >= 11 and <= 50
- green background if the result is >51
what am i doing wrong? seems like the currentfield value is not set as the txtContent, how eventually fix this?