How to highlight the custom start date field with red color on form view and list view of table if the start date is in past?

Community Alums
Not applicable

Hi Experts,

I have one requirement to highlight the start date field with red color if the date is in past if we compare with the current date when we are filling the form. Please give your inputs on this.

Best Regards,

Prachi

1 ACCEPTED SOLUTION

Hi Prachi,

Use the code - 

javascript: GlideDateTime.subtract(new GlideDateTime(current.avventer_svar_innen),  new GlideDateTime()).getDayPart() > 0;

Refer the community article - https://community.servicenow.com/community?id=community_question&sys_id=4e8a6f36db81041023f4a345ca961997

Regards,

Deepankar Mathur

View solution in original post

6 REPLIES 6

suvro
Mega Sage
Mega Sage

You can configure background color from styles.

 

From the form go to Configure -> All there you will get styles. You can configure style for every field based on conditions

Chetan Mahajan
Kilo Sage
Kilo Sage

Hi Prachi,

                You have to Configure field style 

Value : javascript: (gs.dateDiff(current.startDate.getDisplayValue(), gs.now(), true)) > 0

Style : background-color:Red;

refer thread :  add style to number Field

Kindly mark correct and helpful if applicable

dmathur09
Kilo Sage
Kilo Sage

Hi Prachi,

You can create style with the given conditions. Refer below screenshot for details

find_real_file.png

javascript:gs.dateDiff(current.due_date.getDisplayValue(),gs.nowDateTime(),true) > 0 ;

Let me know in case of any queries.

If you think my response is helpful for you? If yes, mark it as correct answer and close the loop so that it would help future readers as well.

Regards,

Deepankar Mathur

Community Alums
Not applicable

Hi Deepankar,

I have created this style but this functions are not working with my scoped application. Is there any replacement for this two functions. 

I was writing this-

javascript:GlideDateTime.subtract(current.start_date.getDisplayValue(), gs.nowDateTime(),true) <0 

Thank you for your reply