How make a field 'True/False red when is true (in form view)?

Kasia5
Tera Contributor

Hi All,

In form view of Requested Item I have a True/False field 'Fast Track'. I would like to make this field red when is true. For example the text 'Fast Track' should be bold and red. How can I achieve this?

Thanks in advance for help

find_real_file.png

2 REPLIES 2

Anand Shukla
Mega Guru

Hi Kasia,

 

You can use the onload client script :

function onLoad() {
   //Type appropriate comment here, and begin script below
   var a = g_form.getValue('u_fast_track');

    if (a == 'true') {

       g_form.getControl('u_fast_track').parentNode.style.backgroundColor = 'red';
       g_form.getControl('u_fast_track').parentNode.style.width = '50px';
    } 
	if(a == 'false') {
        g_form.getControl('u_fast_track').parentNode.style.backgroundColor = 'none';
    }

}

Mark it helpful and Correct

 

Thanks and Regards

Anand Shukla

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can use onLoad client script

function onLoad() {
	//Type appropriate comment here, and begin script below
	var val = g_form.getValue('u_fast_track').toString();

	if (val == 'true') {
		g_form.getControl('u_fast_track').style.backgroundColor = 'red';
	} 
}

Regards
Ankur

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