background color of field not working in client script
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2022 10:19 PM
Hi everyone , I want to change the background color of field Resudual Risk(u_priority) string field with choices , Writing one onload client script but not working please see below
Code : onload client script
code is going inside if and getting alert but background color is not changing
var element = g_form.getElement('u_priority');
// alert(element);
var accessType = g_form.getValue('u_priority');
if (accessType == 'Low') {
alert(accessType);
element.style.backgroundColor = "LimeGreen";
}
if (accessType == 'Medium') {
alert(accessType);
element.style.backgroundColor = "yellow";
}
if (accessType == 'High') {
alert(accessType);
element.style.backgroundColor = "orange";
}
if (accessType == 'Well Controlled') {
alert(accessType);
element.style.backgroundColor = "green";
}
if (accessType == 'Critical') {
alert(accessType);
element.style.backgroundColor = "red";
}
Labels:
- Labels:
-
Scripting and Coding
10 REPLIES 10
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2023 10:04 PM
Hi @rushabhgupta,
Hope you have gone through my above comments. Let me know if have any issues.
If my response helps you resolve your issue. Kindly mark it as helpful & correct. It will be helpful to future readers! 👍🏻
Thanks,
Sagar Pagar
The world works with ServiceNow