onChange script error: TypeError: gel is not a function function () { [native code] }

Tom_SCC
Giga Expert

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] }

1 ACCEPTED SOLUTION

Tom_SCC
Giga Expert

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;

} }

View solution in original post

3 REPLIES 3

Tom_SCC
Giga Expert

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 🙂

vkachineni
Kilo Sage
Kilo Sage

Check the value of isolated script field.

 

find_real_file.png

Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022

Tom_SCC
Giga Expert

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;

} }