Change Management States

rachelconstanti
Mega Sage

What do I need to do to prevent users with the 'itil' role from seeing a state in the choice list.

Prior to a recent upgrade itil users could not see the 'review' state or the 'closed' state.  We had this locked down to just the change_manager role.  

I cannot see how to revert this back but this is a huge issue for us because our CAB team wants to review changes and close them - now everyone can do this.

1 ACCEPTED SOLUTION

JP - Kyndryl
Kilo Sage

Hi Rachel,

Ok,  I found why.

There is another client script that is showing the next possible State values,  so you need to make sure your script has an Order higher that this one to be executed after this one.

JPKyndryl_0-1673278309255.png

I just tested Order of 200 and it works fine.

 

Regards,
JP

View solution in original post

6 REPLIES 6

JP - Kyndryl
Kilo Sage

Hi Rachel,

You will have to create an OnLoad client script to remove the Review value, unless the user has the change_manager role. 

Here is the documentation for the script:  https://servicenowguru.com/scripting/client-scripts-scripting/removing-disabling-choice-list-options...

The internal value for the change_request.state of "Review" is 0.

 

JPKyndryl_0-1673042067861.png

 

Regards,
JP

Hi JP - thank you for the response.  After further review we only need to hide the closed state.  I do have a 'restrict close' onLoad Client Script for this which is active and looks like this:

 

function onLoad() {
var isAdmin = g_user.hasRole('change_manager');
var state = g_form.getValue('state');
if (!isAdmin && (state != 3)){
//alert('Current user is not an admin');
g_form.removeOption('state', '3');
}
}

 

Any ideas as to why this would stop working?  (I have verified that only 3 users have the change_manager role) but everyone can close a change request.

I've also attached the change request state values

JP - Kyndryl
Kilo Sage

Hi Rachel,

Try this:

 

// Hide "Closed" Change State from everyone but change_manager

function onLoad() {
if (g_user.hasRole('change_manager'))
    return;

if (g_form.getValue('state') != '3')
    g_form.removeOption('state', 3);
}

 

 

 

 

 

Regards,
JP

Hi JP,

I set the original script to inactive.  Created a new one and the behavior is the same...

itil users can still see the closed state...

Rachel