How to add style to number Field

venu palleboin1
Kilo Contributor

hi everyone,

Add the style to number field

if records are created today those records are visible in green color.

if records created in yesterday and day before yesterday that records shown as blue color.

and remaining records are shown in red color.

 

  

1 ACCEPTED SOLUTION

@venu palleboina 

Hope you are doing good.

Did my reply answer your question?

If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

4 REPLIES 4

Chetan Mahajan
Kilo Sage
Kilo Sage

Hi Venu,

                 you have to create 3 field styles as below in value you can add code as per requirement.

  1. Log in to a demo instance.

  2. Navigate to System UI > Field Styles and click New.

  3. Create two new styles with the following values, and click Submit after creating each one.

    Style 1:
    Table: incident
    Field name: number
    Value: javascript:true
    Style: background-color:red

Reference Article : Field styles

 

Kindly mark correct and helpful if applicable

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

create 2 field styles 1 for every color

Green

javascript: new GlideDateTime(current.sys_created_on).getDate() == new GlideDateTime().getDate()

find_real_file.png

Blue

javascript: new GlideDateTime(current.sys_created_on).getNumericValue() < new GlideDateTime().getNumericValue()

find_real_file.png

Red - you won't have records created in future -> So this is not required

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@venu palleboina 

Hope you are doing good.

Did my reply answer your question?

If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

arun38
Tera Contributor

We can use g_form.flash also