- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2019 07:24 AM
Trying to set background off custom risk field based on value. Using the below script
function onChange(control, oldValue, newValue, isLoading) {
var elementID = gel("Risk Score");
switch(newValue) {
case "1": elementID.style.backgroundColor = "lightgreen"; break;
case "2": elementID.style.backgroundColor = "lightgreen"; break;
case "3": elementID.style.backgroundColor = "lightgreen"; break;
case "4": elementID.style.backgroundColor = "yellow"; break;
case "5": elementID.style.backgroundColor = "yellow"; break;
case "6": elementID.style.backgroundColor = "yellow"; break;
case "8": elementID.style.backgroundColor = "yellow"; break;
case "9": elementID.style.backgroundColor = "yellow"; break;
case "10": elementID.style.backgroundColor = "orange"; break;
case "12": elementID.style.backgroundColor = "orange"; break;
case "15": elementID.style.backgroundColor = "orange"; break;
case "16": elementID.style.backgroundColor = "orange"; break;
case "20": elementID.style.backgroundColor = "red"; break;
case "25": elementID.style.backgroundColor = "red"; break;
default: elementID.style.backgroundColor = "white"; break; } }
This is not working and bringing error message - onChange script error: TypeError: gel is not a function function () { [native code] }
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2019 08:04 AM
Thanks for the response, however i have fixed myself using the below
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '')
switch(newValue) {
case "1": control.style.backgroundColor = "lightgreen"; break;
case "2": control.style.backgroundColor = "lightgreen"; break;
case "3": control.style.backgroundColor = "lightgreen"; break;
case "4": control.style.backgroundColor = "yellow"; break;
case "5": control.style.backgroundColor = "yellow"; break;
case "6": control.style.backgroundColor = "yellow"; break;
case "8": control.style.backgroundColor = "yellow"; break;
case "9": control.style.backgroundColor = "yellow"; break;
case "10": control.style.backgroundColor = "orange"; break;
case "12": control.style.backgroundColor = "orange"; break;
case "15": control.style.backgroundColor = "orange"; break;
case "16": control.style.backgroundColor = "orange"; break;
case "20": control.style.backgroundColor = "red"; break;
case "25": control.style.backgroundColor = "red"; break;
} }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2019 07:30 AM
I have also tried
var elementID = gel("risk.risk score"); and var elementID = gel("risk.u_risk_level"); don't ask why the name is different than the label, it's in test 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2019 07:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2019 08:04 AM
Thanks for the response, however i have fixed myself using the below
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '')
switch(newValue) {
case "1": control.style.backgroundColor = "lightgreen"; break;
case "2": control.style.backgroundColor = "lightgreen"; break;
case "3": control.style.backgroundColor = "lightgreen"; break;
case "4": control.style.backgroundColor = "yellow"; break;
case "5": control.style.backgroundColor = "yellow"; break;
case "6": control.style.backgroundColor = "yellow"; break;
case "8": control.style.backgroundColor = "yellow"; break;
case "9": control.style.backgroundColor = "yellow"; break;
case "10": control.style.backgroundColor = "orange"; break;
case "12": control.style.backgroundColor = "orange"; break;
case "15": control.style.backgroundColor = "orange"; break;
case "16": control.style.backgroundColor = "orange"; break;
case "20": control.style.backgroundColor = "red"; break;
case "25": control.style.backgroundColor = "red"; break;
} }