The CreatorCon Call for Content is officially open! Get started here.

Change color of field Text

Neeraj Sharma10
Tera Guru

Hello experts,

How can we change the color of text in the field?

I tried

var myVar = $('sys_display.' + g_form.getControl('cmdb_ci').id);

myVar.style.setStyle({color: "white"});

but this do not works.!

Thanks in advance

1 ACCEPTED SOLUTION

Hi Amlan Pal



With the help of Client script able to change the color of the text.



var myVar = $('sys_display.' + g_form.getControl('cmdb_ci').id);


myVar.setStyle({color: "white"});



The problem was (.style) which i added out of no where.


Still trying to figure out why on earth i did that.



Thanks for the help


Cheers



Regards


Neeraj Sharma


View solution in original post

13 REPLIES 13

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

Hi,



Use the OOB thing called field styles for this.



Define field styles



//Göran


Hi Goran Lundqvist


Thanks for the reply



I think field styles affect the list layout only. I want to change the Text color of the field in the form (let say everything written inside short description should be red)



Regards


Neeraj Sharma


Hi,



Nope it's not only list. "Field styles allow you to declare individual CSS styles for a field in a list or form."



//Göran


Hi,


But whenever i giving some condition in the value field of the field styles, color of the field only change in the list view,   On the form color do not change.



Untitled2.png



But when i see list view color is green


Untitled2.png