- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2023 09:10 AM
Hi Team,
I need help in applying color to field in a list view. The field is End date(end_date) and condition is like if end date is before this month then i need to mark them in a color.
Kindly help , Thanks
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2023 11:19 AM - edited 03-01-2023 11:33 AM
Have you tried to use a style? Right-mouse-click the field in the list and configure all. Then click the Style tab and create a new style. Select the field and put something like: javascript:(current.ends.getGlideObject().compareTo(new GlideDate()) < 0); in the value and background-color: red; in the Style.
compareTo
0 = Dates are equal
1 = The object's date is after the date specified in the parameter
-1 = The object's date is before the date specified in the parameter

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2023 11:19 AM - edited 03-01-2023 11:33 AM
Have you tried to use a style? Right-mouse-click the field in the list and configure all. Then click the Style tab and create a new style. Select the field and put something like: javascript:(current.ends.getGlideObject().compareTo(new GlideDate()) < 0); in the value and background-color: red; in the Style.
compareTo
0 = Dates are equal
1 = The object's date is after the date specified in the parameter
-1 = The object's date is before the date specified in the parameter

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2023 11:21 AM - edited 03-01-2023 11:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2025 12:01 AM - edited 07-14-2025 12:01 AM
I have applied the same but it is not showing the field color as red or yellow. Pls let me know the issue
javascript: (current.u_next_renewal_date.getGlideObject().compareTo(new GlideDate()) = 0);
javascript: (current.u_next_renewal_date.getGlideObject().compareTo(new GlideDate()) = 15);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2025 06:13 AM
Hey @Naman Jain2412 , the javascript just tells it when to use the style. The style (background-color: red;) is what determines the color. What do you have in the style field? Based on your javascript, it should be turning the values in which u_next_renewal_date is equal to today. As for the 15, that is not a valid value. 0=equal, 1=greater than and -1=less than. If you are trying to style where the u_next_renewal_date is the 15th, then you'll have to check the date() to get which day it is. Hope that makes sense.