Apply color to a field in a list view

maneesh3
Tera Contributor

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.

maneesh3_0-1677690565096.png

 

Kindly help , Thanks

 

 

1 ACCEPTED SOLUTION

cgedney
Giga Guru

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&colon;(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

 

View solution in original post

5 REPLIES 5

cgedney
Giga Guru

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&colon;(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

 

 

cgedney_0-1677699263472.png

 

I have applied the same but it is not showing the field color as red or yellow. Pls let me know the issue
javascript&colon; (current.u_next_renewal_date.getGlideObject().compareTo(new GlideDate()) = 0);
javascript&colon; (current.u_next_renewal_date.getGlideObject().compareTo(new GlideDate()) = 15);

 

 

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.