Need help with Client script on the incident table for Impact and Urgency fields ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2024 09:07 PM
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 ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 01:54 AM
Hi @Harish KM - Have pinged you on ServiceNow messenger
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2024 09:33 PM
Hello @Pooja Khatri ,
1. Please try to use below OnChnage client script if impact changes:
var userRole = g_user.hasRole('itil'); // check manager role here
if (!userRole) {
var getImpact = g_form.getValue('impact'); // get selected impact value
if (getImpact == 1) // impact value 1 for widespread
{
g_form.removeOption('urgency', '1'); // remove High choice from Urgency
alert ('Only Managers are allowed to select values');
}
}
2. Please try below OnChange client script if urgency changes:
var userRole = g_user.hasRole('itil'); // check manager role here
if (!userRole) {
var getUrgency = g_form.getValue('urgency'); // get selected urgency value
if (getUrgency == '1') // urgency value '1' for High
{
g_form.removeOption('impact', '1'); // remove Widespread choice from Impact
alert ('Only Managers are allowed to select values');
}
}
Let me know your views on this and Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
Pratiksha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2024 09:40 PM
Hi @Pratiksha2 - I tried with the below script for impact :

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2024 09:49 PM
Hi @Pratiksha2 there is a error in your script
var userRole = g_user.hasRole('manager'); // check manager role here
if (!userRole) {
var getImpact = g_form.getValue('impact'); // get selected impact value
if (getImpact == 1) // impact value 1 for widespread
{
g_form.removeOption('urgency', 1); // there should be no single codes here, like this '1'
alert('Only Managers are allowed to select values');
}
}
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2024 09:51 PM
Hello @Pooja Khatri ,
Please try using below code,
var userRoles = g_user.getRoles();
if (userRoles.indexOf('manager') === -1) { // execute if 'itil' role is not found
var getImpact = g_form.getValue('impact'); // get selected impact value
if (getImpact == 1) // impact value 1
{
g_form.removeOption('urgency', '1'); // remove High choice from Urgency
alert('Only Managers are allowed to select values');
}
}
Let me know your views on this and Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
Pratiksha