Trying to create new client script for Major Incidents

astruphar
Giga Contributor

Hello, I am trying to create a new client script that allows users with the 'major_incident_manager' role the ability to ONLY close major incidents. I am basing it off the current script in the OOB client script "(BP) Hide Choice - Closed" but I am not having much luck with the script.

Basically, the script needs to check 2 things:

1) if g_form.getValue('major_incident_state') == 'accepted'

2) if g_user.hasRole('major_incident_manager')

If both of these match, the statement should end and nothing should happen.

 

If it doesn't match (meaning it's either a regular incident or the user does not have the appropriate role), then the OOB script should apply as below:

 

if (g_form.getValue('incident_state') != '7')
g_form.removeOption('incident_state', 7);
if (g_form.getValue('state') != '7')
g_form.removeOption('state', 7);

8 REPLIES 8

Oh okay. 

If that is the case then you are absolutely right. If first if Conditions met then it will return without running next line of code.


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

Okay thank you for verifying. Now I'm wondering why it's not working. Both of the if conditions are being met, so it shouldn't be moving to the next lines of code.

Just remove everything after return and check wheather you are getting same result or different 


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

Oh I just realized that what you initially posted is the inverse of what I'm trying to do and that might work. Let me check.