- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2023 10:52 AM
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.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 07:32 AM
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.
I just tested Order of 200 and it works fine.
JP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2023 01:55 PM
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.
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 05:12 AM - edited 01-09-2023 05:31 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 05:41 AM
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);
}
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 05:54 AM
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