I am able to change the color by using OnChange client Script, Can someone help me with that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2022 04:34 AM - edited 10-14-2022 05:32 AM
I've 2 choices in the field, I am able to change the choice color by using OnChange client Script, But the background color disappearing, after saving the record. The background color should stay, after saving the record also for single choice, Please someone suggest me with that. Below is my code.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var field = g_form.getValue('u_risk_type');
if (field == 'specialty_lines') {
var riskType = g_form.getControl('u_risk_type');
riskType.style.backgroundColor = "#A9E2F3";
} else {
if (field == 'complex') {
//control.style.backgroundColor = "white";
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2022 07:31 AM
Please find the updated code below:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (newValue === '') {
return;
}
var field = g_form.getValue('u_risk_type');
if (field == 'specialty_lines') {
var riskType = g_form.getControl('u_risk_type');
riskType.style.backgroundColor = "#A9E2F3";
} else {
if (field == 'complex') {
//control.style.backgroundColor = "white";
}
}
}
As this also need to be executed on loading so you just need to remove 'isLoading' from 2nd line so it can run while loading also.
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023