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

No, i mean in native view and in portal ?

and can we increase the size of the text ?

Can we set only some part of the text Red ? ie "This is Test " just Test in red color

Hi,

the above script would work well in catalog item view and once RITM is generated.

It won't work in portal as jquery has issue on potal

not sure if you can make some part of text as Red but that also would work in native and not in portal if it is achieved

Regards
Ankur

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

Gaurav Shirsat
Mega Sage

Hi Kam

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

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

try using client scripts

https://www.servicenowguru.com/system-ui/ui-scripts-system-ui/modifying-label-form-fields-client-scr...

https://community.servicenow.com/community?id=community_question&sys_id=1d076eefdbffd74067a72926ca96...

 

Please Mark Correct and Helpful

Thanks and Regards

Gaurav Shirsat

 

 

sachin_namjoshi
Kilo Patron
Kilo Patron

Please check below  for solution to change label color for service portal and platform view

 

https://community.servicenow.com/community?id=community_question&sys_id=45f7cb2ddb1cdbc01dcaf3231f9619fb

 

Regards,

Sachin

cashmere
Giga Contributor

Hi thanks for your help i was looking for the same thing too

 SHAREit MX Player