Forum Discussion
SharePoint List color rows based upon date ranges relative to the Due Date
- Jan 12, 2021
For SharePoint 2013, you can use Client Side Rendering (CSR) which represents a rendering engine for list views.
You can refer the code samples given in below links and modify it according to your conditions:
- How to highlight the row in red if expiration date is passed for SharePoint 2013 list
- SharePoint 2013 on-prem conditional formatting row by dueDate
Please click Mark as Best Response if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
Are you using SharePoint Online and modern lists experience? For modern lists experience view formatting is done with JSON.
Matti PaukkonenI am not. We are using SharePoint 2013 on-premise
- ganeshsanapJan 12, 2021MVP
For SharePoint 2013, you can use Client Side Rendering (CSR) which represents a rendering engine for list views.
You can refer the code samples given in below links and modify it according to your conditions:
- How to highlight the row in red if expiration date is passed for SharePoint 2013 list
- SharePoint 2013 on-prem conditional formatting row by dueDate
Please click Mark as Best Response if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
- Joseph_ButlerJan 13, 2021Copper Contributor
ganeshsanapIt appears the the code offered in the links provided allow me to color code items,
However, I am not finding the code needed in order to complete the "else if" regarding date ranges.
I have done extensive searches on Google and just not seeing the code needed. Any ideas?
- Joseph_ButlerJan 13, 2021Copper Contributor
for example:
For the following code, I get it...if the DueDate field for the row is less than Today, then the row will be red.
else if (dueDate < now) { row.style.backgroundColor ='red' ; }
What I would like to is set this to if the DueDate field for the row is 13 days out or less from Today, the the field should be red. When I make the changes below, it does not work.
else if (dueDate <= now+13) { row.style.backgroundColor ='red' ; }
Granted, I know nothing about scripting, other than guessing and I haven't found anything on Google that shows how to do this.