Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

How to add javascript to value field?

Jared Wason
Tera Guru

Hi,

I am trying to set the background of a field to blue if the user has more than 1 PC assigned to them. I believe my script include is setup properly since it worked when running it in Background-Script, I think I just need to adjust "if(javascript:countAssignedTo(current.u_itd_customer))>1;". Anyone know how I need to adjust this?

 

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

kindly have a look on below article. it has mentioned the details. 

 

https://www.servicenowelite.com/blog/2013/11/24/custom-field-styles

View solution in original post

8 REPLIES 8

hvrdhn88
Giga Patron

try now

 

javascript:countAssignedTo(current.u_itd_customer)>1

you dont need to use if() in value field 

Hi, I tried that and still doesn't work for me. I have even tried 'javascript:1>0' just to test and it still isn't triggering my style rule. 

just confirming here.

how are you testing it ? because when you apply some condition on "value" field then field style will be applicable for list view. 

 

condition which i had suggested is correct and it will work. please confirm where are you testing it ? on list or form ?

javascript:countAssignedTo(current.u_itd_customer)>1