Each time the state field changes, number fields background colour should be changed

Not applicable

Each time the state field changes, number fields background colour should be changed

5 REPLIES 5

Bhavya11
Mega Patron

hi @Community Alums 

 

you can try below code 

 

function onLoad() {
   //Type appropriate comment here, and begin script below
    var element = g_form.getElement('number');
   if (g_form.getValue('state') == 3) {
        element.style.backgroundColor = "red";
    }else if(g_form.getValue('state') == 1){
		element.style.backgroundColor = "green";
	}
}

 

 

 

If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful."

 

 

Thanks,

BK

Not applicable

not working

Anurag Tripathi
Giga Patron

You can use field styles for the sale. that would work on List view as well as form.

Define field styles (servicenow.com)

SN_Learn
Mega Patron