The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Field Styles: True/False Condition & Dot-walk

Desmo
Mega Guru

Hello Community,

Table: Company (core_company)

Q1: How to set background color using condition with a true/false checkbox

I can set the background color of the Name field using background: red;

There is a true/false checkbox (Test) on the form. In the Value field I out:

  • javascript: current.u_test == 'true' (Does not work)
  • javascript: current.u_test == "true" (Does not work)
  • javascript: current.u_test == true (Does not work)

 

Q2: How to get the same field style into another table that references the core_company record?

Table: Incident (incident)

Can I use a dot-walk in the Value field, i.e. javascript: current.company.u_test == 'true'?

 

Thank you!

1 ACCEPTED SOLUTION

Willem
Giga Sage
Giga Sage

Hi Desmo,

Q1: javascript: current.u_test == true <--should work

Do you have another style record set up for this?

I tried the following and it works:

find_real_file.png

find_real_file.png

 

Q2: Yes, dot walking is allowed:

find_real_file.png

find_real_file.png

find_real_file.png

View solution in original post

3 REPLIES 3

Willem
Giga Sage
Giga Sage

Hi Desmo,

Q1: javascript: current.u_test == true <--should work

Do you have another style record set up for this?

I tried the following and it works:

find_real_file.png

find_real_file.png

 

Q2: Yes, dot walking is allowed:

find_real_file.png

find_real_file.png

find_real_file.png

Hi Willem,

Thank you for taking the time to test. 

Dot walking is working now. I see the color next to the name on list view. What's interesting is when I open the record and view it on a form, the name field does not have the background color. When I remove the condition in Field Styles value field, then the field is colored.

 

Desmo

bernyalvarado
Mega Sage

Hi @Desmo , I believe that a background style will not work in a checkbox type of field. I'm not sure why, because Javascript does support it, but apparently it just doesn't work in ServiceNow field styles. 

One option is if you have a Choice type of field with a true and a false choices. That field type does support a Field Style.

Thanks,

Berny