Change the color of a label field

RudhraKAM
Tera Guru

Hi

How do we change the color of a label field on catalog item and service portal 

 

We have  a label name u_test  which has a question" this is test "

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Do you want the color when form loads?

if yes then use onLoad client script

Ensure Isolate Script is set to false for this client script; this field is not on form but from list you can make it false

function onLoad(){

var getLblParent= g_form.getElement('u_test').id.replace('sys_original.','');

var getLblElement = $j("label[for='"+getLblParent+"']").css('color','red');


}

find_real_file.png

Isolate Script: False

find_real_file.png

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

View solution in original post

13 REPLIES 13

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Do you want the color when form loads?

if yes then use onLoad client script

Ensure Isolate Script is set to false for this client script; this field is not on form but from list you can make it false

function onLoad(){

var getLblParent= g_form.getElement('u_test').id.replace('sys_original.','');

var getLblElement = $j("label[for='"+getLblParent+"']").css('color','red');


}

find_real_file.png

Isolate Script: False

find_real_file.png

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Thanks ankur , will this work in portal too ? if we select UI type as both ?

Can you please explain the code ?

Hi Kam,

Are you saying whether it would work on Catalog Item view and RITM view also?

UI Type as ALL

It searches for the text using jquery

Regards
Ankur

 

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