Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Need help with Client script on the incident table for Impact and Urgency fields ?

Pooja Khatri
Tera Contributor

Hello All ,

I have a requirement where in my Incident form there are two drop down fields - Impact and Urgency
in Impact the options are : 1 - widespread , 2 - significant , 3 - moderate , 4 - contained , 5 - isolated


and in Urgency we have option : High , Medium High , Normal

 

so for all the users other than the manager role , if the user selects and option of 1 - widespread in IMPACT it should hide the option for High in URGENCY and
if they select High in URGENCY it should hide the option of 1-widespread in IMPACT


and it should throw and alert message saying 'Only Managers are allowed to select values'

 

How can I implement this functionality ?

19 REPLIES 19

Harish KM
Kilo Patron
Kilo Patron

Hi @Pooja Khatri you would need 2 onchange client scripts.

1. onchange client script on Impact field

script:

    var userRole = g_user.hasRole('itil');// check manager role.here i am checking if loggedin user has itil role
   alert(userRole);
   var getImpact = newValue; // selected imact value
   if(!userRole && getImpact == 1) //impact value 1 for high
   {
alert(''Only Managers are allowed to select values');
    g_form.removeOption('urgency',1); // remove hight choice from Urgenct
   }
2. onChange client script on Urgency field
script:
    var userRole = g_user.hasRole('itil');// check manager role.here i am checking if loggedin user has itil role
   alert(userRole);
   var getUrgency = newValue; // selected urgency value
   if(!userRole && getUrgency == 1) //impact value 1 for high
   {
alert(''Only Managers are allowed to select values');
    g_form.removeOption('impact',1); // remove high choice from impact
   }
Regards
Harish

Hi @Harish KM - I tried with the below script for impact field : 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    var userRole = g_user.hasRole('manager');
    alert(userRole);
    var getImpact = impact; // selected impact value
    if (getImpact == 1) //impact value 1 for high
    {
        alert('Only Managers are allowed to select values ');
            g_form.removeOption('urgency', 1);
        }
    }
 
but the script is not working and also it is giving me the below error on my incident form : 
 
PoojaKhatri_0-1706765487431.png

 

Hi @Pooja Khatri 

var getImpact = newValue; //this should be newValue not impact

Or use below line

Var getImpact = g_form.getValue('impact');

Regards
Harish

Hi @Harish KM - this did helped me and fixed the issue , but now I am facing just one issue if the urgency or Impact is changed from high to any other value back it is still hiding the options .

 

How can I fix this ?