Forum Discussion
Joseph_Butler
Mar 12, 2021Copper Contributor
Color Code SharePoint List cell based on Due Date and Status columns
I am using the Javascript (at the bottom) on my SP 2013 site to color code a Due Date field. This code as written, does just that. However, if the Status column for the list item is set to Co...
- Mar 15, 2021
Not sure if this is exactly what you need. You should be able to modify where this code is located.
Before the first line of code in your, add the following.
if (!ctx.CurrentItem.DueDate || ctx.CurrentItem.Status.toLowerCase() === "completed") return;
This checks if the DueDate exists and then if the Status = Complete. If either condition is true, the function exits (return;)
If this works for you, please mark this response as the answer. Thanks!
Don Kirkham
Mar 15, 2021MVP
Not sure if this is exactly what you need. You should be able to modify where this code is located.
Before the first line of code in your, add the following.
if (!ctx.CurrentItem.DueDate || ctx.CurrentItem.Status.toLowerCase() === "completed") return;
This checks if the DueDate exists and then if the Status = Complete. If either condition is true, the function exits (return;)
If this works for you, please mark this response as the answer. Thanks!
Joseph_Butler
Mar 15, 2021Copper Contributor
The code provided removes the date from the Due Date field., so I updated it with the color:
if (!ctx.CurrentItem.DueDate || ctx.CurrentItem.Status.toLowerCase() === "completed")
return "<div style='background-color:white;color:black'>" + ctx.CurrentItem.DueDate + "</div>";
if (!ctx.CurrentItem.DueDate || ctx.CurrentItem.Status.toLowerCase() === "completed")
return "<div style='background-color:white;color:black'>" + ctx.CurrentItem.DueDate + "</div>";