Conditional formatting for date column randomly stopped working

Copper Contributor

This applies to Sharepoint Online (Office 365), new experience lists.

 

I have some formatting set on a non-date column, which looks at a date column called "next deadline". This date column is automatically calculated based on other columns.

 

For about a year, this column formatting worked, and would display deadlines by colour, depending on how close they are to now (red, amber, green).

 

Randomly one day, I think it was about August of 2018, this stopped working, and now shows ALL deadlines in green.

 

Can anyone spot an error, or provide a solution?

 

Here's the code I wrote, which definitely worked for 6-12 months after I wrote it!

 

My apologies for the formatting of the code below, I tried but wasn't able to format it properly as code, with correct indentation.

 

 

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"debugMode": true,
"elmType": "div",
"txtContent": "@currentField",
"attributes": {
"class": {
"operator": "?",
"operands": [
{
"operator": "<=",
"operands": [
"[$Next_x0020_Deadline]",
1
]
},
"",
{
"operator": "?",
"operands": [
{
"operator": "<=",
"operands": [
"[$Next_x0020_Deadline]",
{
"operator": "+",
"operands": [
"@now",
86400000
]
}
]
},
"sp-field-severity--severeWarning",
{
"operator": "?",
"operands": [
{
"operator": "<=",
"operands": [
"[$Next_x0020_Deadline]",
{
"operator": "+",
"operands": [
"@now",
259200000
]
}
]
},
"sp-field-severity--warning",
"sp-field-severity--good"
]
}
]
}
]
}
}
}

2 Replies
Try removing the quotes from the @nows and if that doesn't do it try to put ' around the 'sp-field-severity--warning' instead of quotes. See if that fixes it, maybe they made it more strict or something on formatting when they released the view formatting or something.

Hi Chris, thanks for your input. I tried all those things you suggested but none of them validated (when I hit save or preview on the column formatting, it says in red "Please enter valid column-formatting JSON.")

 

Any other ideas? It's pretty strange that it stopped working. On the docs page for Sharepoint List column formatting, I note there's a closed issue that someone else had for something that stopped working around the same time, which could be related:

 

cond-form.png