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

Hi @Pooja Khatri In that case add a else part like this

if (getImpact == 1) //impact value 1 for high
{
alert('Only Managers are allowed to select values ');
g_form.removeOption('urgency', 1);
}

 else{
    g_form.addOption('urgency',1);
   }
Regards
Harish

Hi @Harish KM - I did try with this but it gave me the below error : 

 

PoojaKhatri_0-1706767707975.png

 

Script I used : 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    var userRole = g_user.hasRole('manager');
    var getImpact = newValue; // selected impact value
    if (getImpact == 1) //impact value 1 for high
    {
        g_form.removeOption('urgency', 1);
    } else {
        g_form.addOption('urgency', 1);
    }
}

Hi @Harish KM - also for users with 'Manager' Role , the options from the URGENCY and IMPACT fields are getting removed - ideally the options should be visible for them in any of the given scenario .

 

How can I fix that part ? 

Hi @Pooja Khatri you need modify the if condition like below

 if(!userRole && getImpact == 1) //impact value 1 for high
Regards
Harish

Hi @Harish KM - Can you help me to fix this one ?