SharePoint lists are great! They are brilliant for many users, allowing much better storage of structured data than Excel spreadsheets.
You can also do simple color coding on SharePoint lists based on simple field values. But a common request I hear from customers is:
How do we color-code the list based on a date column in the SharePoint list?
So for example, if a To Do list in SharePoint has a field called "Due Date", how can we color code it so that rows are green if the due date is more than 30 days away, yellow if the due date is within 30 days, and red if the due date is in the past?
It's not at all clear how to do this in the SharePoint View formatting screen, but luckily there is a way to do it!
See how in this little video, and see below for the code snippet used. Slightly tricky, but easy when you know how! 🤓
Format View JSON - this is the code used in the video
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
"additionalRowClass": "=if([$DueDate] >= @now + 2592000000, 'sp-field-severity--good', if([$DueDate] >= @now, 'sp-field-severity--warning', 'sp-field-severity--blocked'))"
}
댓글