Forum Discussion
Rense620
Oct 25, 2022Copper Contributor
JSON change color of row based on date column
I am looking for a JSON code that changes de color of the ROW to red if it is 200 days after the date of a column. So the column says 10/12/2022 (dd/mm/jjjj) And if it today 200 days after that d...
- Oct 26, 2022
Rense620 Use JSON view formatting code like below:
{ "schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json", "additionalRowClass": "=if(addDays([$Modified], 190) < @now && addDays([$Modified], 200) > @now, 'sp-field-severity--warning', if(addDays([$Modified], 200) < @now, 'sp-field-severity--blocked', ''))" }Documentation: view-list-formatting
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
Rense620
Oct 25, 2022Copper Contributor
I tried this code but it doesn't work.
{
"schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
"additionalRowClass": "=if([$Modified] < @now && [$Modified] >= @now + 172800000, 'sp-field-severity--blocked', if([$Modified] < @now && [$Modified] >= @now - 86400000, 'sp-field-severity--warning' , ''))"
}
The color must be yellow from 190 day after the checked date.
And after 200 days it must be red for ever till the document is checked and the date is changed.
{
"schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
"additionalRowClass": "=if([$Modified] < @now && [$Modified] >= @now + 172800000, 'sp-field-severity--blocked', if([$Modified] < @now && [$Modified] >= @now - 86400000, 'sp-field-severity--warning' , ''))"
}
The color must be yellow from 190 day after the checked date.
And after 200 days it must be red for ever till the document is checked and the date is changed.
ganeshsanap
Oct 26, 2022MVP
Rense620 Use JSON view formatting code like below:
{
"schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
"additionalRowClass": "=if(addDays([$Modified], 190) < @now && addDays([$Modified], 200) > @now, 'sp-field-severity--warning', if(addDays([$Modified], 200) < @now, 'sp-field-severity--blocked', ''))"
}
Documentation: view-list-formatting
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
- Rense620Oct 26, 2022Copper Contributor
That did the trick!
First I made a little typo... 🙂
Thank you very much for you help!