Forum Discussion
Jennife_r
Jun 06, 2024Copper Contributor
Formatting a Date Column to be red if expired, and gold is expiring within 5 days.
I know similar things have been asked but I can't find any available solutions that I could successfully tweak to work. Whenever I think I get close the formatting just makes the dates disappear 🤦:...
- Jun 07, 2024
I was able to solves this using AI (after MUCH back and forth and rewording).
The code that worked is ...
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "txtContent": "@currentField", "attributes": { "class": "=if(Number(@currentField) == 0, '', if(@currentField <= @now, 'sp-css-backgroundColor-BgCoral sp-css-borderColor-CoralFont sp-field-fontSizeSmall sp-css-color-CoralFont', if(@currentField <= @now + 432000000, 'sp-css-backgroundColor-BgGold sp-css-borderColor-GoldFont sp-field-fontSizeSmall sp-css-color-GoldFont', '')))" } }
I hope this helps someone else!!
Jennife_r
Jun 07, 2024Copper Contributor
I was able to solves this using AI (after MUCH back and forth and rewording).
The code that worked is ...
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"attributes": {
"class": "=if(Number(@currentField) == 0, '', if(@currentField <= @now, 'sp-css-backgroundColor-BgCoral sp-css-borderColor-CoralFont sp-field-fontSizeSmall sp-css-color-CoralFont', if(@currentField <= @now + 432000000, 'sp-css-backgroundColor-BgGold sp-css-borderColor-GoldFont sp-field-fontSizeSmall sp-css-color-GoldFont', '')))"
}
}
I hope this helps someone else!!