Forum Discussion
RebeccaBB
May 14, 2021Copper Contributor
Add a column for traffic light for a Due Date
Hello - I need to create a traffic light or colored dot for a Modern SharePoint list of policies that need to be updated each year. The list, below, shows a Due Date for each item ...
RobElliott
May 17, 2021Silver Contributor
Hi RebeccaBB, you can do this with the following JSON (based on your criteria). Time comparisons in JSON are done in milliseconds.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"background-color": "=if([$Due] < @now, '#780909', (if([$Due] >= @now && [$Due] <= @now+259200000, '#e74c3c', (if([$Due] >= @now && [$Due] <= @now+864000000, '#f39c12', '#98a148')))",
"width": "20px",
"border-radius": "25px"
}
}
Which gives the following result:
Rob
Los Gallardos
Intranet, SharePoint, Website and Power Platform Manager (and classic 1967 Morris Traveller driver)
- RebeccaBBMay 21, 2021Copper ContributorHi Rob,
Thank you for providing this to me. I copied it into the formula field and all the items on my list are still showing as Red/ Overdue. I tried changing to Classic view, but that did not correct the error. I also changed the field called Due Date from being a calculated field to be one where the user has to manually enter the due date. This worked! But when I closed the folder and reopened it, everything was back to showing as Red/ Overdue. Do you have any insight on why this is not working?