Forum Discussion
JSON Date Range Help
eenochs-turner yes it's possible to do this. Up until the warranty expiry date in the example below the date is colored black, but if the warranty expiry is earlier than today it's red.
The syntax for the JSON on the Warranty column is:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"color": "=if([$Warranty] < @now, '#c64444', '#000000')"
}
}
But you can also format it with the built-in standard column formatting without any need for JSON:
Rob
Los Gallardos
Microsoft Power Automate Community Super User
Rob thank you for the response but i went a different route and I'm almost there. This is the JSON command i went with and its working but now i have a issue with blank entries.
{
"$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] +31556952000 <= @now, '#ff0000', '#000000')"
}
}
The Issue I'm having now is how can i add a statement to this to ignore any entry that is blank. In this list there will be blank entries as not every item has a warranty period.
- Holman GutierrezApr 06, 2021Copper Contributor
eenochs-turner This works to change font color. How do I also change background color? Thank you.
- RobElliottApr 06, 2021Silver Contributor
Holman Gutierrez you add a comma after the previous line then add another line with
"background-color": "#c00000"
or whatever color you want.Rob
Los Gallardos
Microsoft Power Automate Community Super User