Forum Discussion

kevingeorget's avatar
kevingeorget
Brass Contributor
Oct 24, 2019

JSON formatting a list view in SharePoint

Hi SharePoint Users,
I need to format a Status column (Single line of text field) based on a Date- Time column for a SP List view. 
The logic-
1. If [DueDate]<Today, then color is Bright Red
2. If [DueDate]=Today, then color is Light red
3. IF [DueDate]>Today, then color is black
I tried the simple logic as below, but since both @currentfield and @now takes the date-time value, i'm not getting the desired results.

 

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"color": "=if([$DueDate] <@now '#ff0000',if([$DueDate] ==@now,'#e89b9b',''))"
}
}
Please help.

Resources