- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2016 03:21 AM
Hi,
Is it possible to make one value in State "read only". What im trying to accomplish is to make State "New" read only for incident, so that this state isn't possible to set manually, only by rules..
Anyone tried anything similar?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2016 03:25 AM
Sorry Anders. It's a function of most browsers that choice lists (aka select lists) display the values they have. You could use an onLoad client script to remove the option.
g_form.removeOption('state', 'New'); //Adjust New to the proper state VALUE, e.g. 1)
Reference:
GlideForm (g form) - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2017 05:32 AM
Hi Ram ramreddy,
This is really useful piece of code. Is there a way to add additional line of code so the option is no longer disabled when a specific value on another field is selected? E.g. If I have a cause code of security, I want it disabled always unless category is security.
Many thanks!
Kamile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2016 03:40 AM
Hi Anders,
You can use a onLoad Client Script to make this value in the choice list always Read Only.
function onLoad() {
var myState = g_form.getValue('state');
if (myState == 1)
g_form.setReadonly('state',true);
}
Hope this helps!
Thanks!
Monica
ServiceNow | Everything as a Service
Please hit Like/Helpful/Correct if applicable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2016 03:44 AM
Hi,
That will make the entire "State" field read only if state = new. I want the option "New" to be "read only" as in not possible to set manually.
If im not mistaken, this code will make it impossible to get out of state "New" manually..?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2016 03:53 AM
You can use UI Policy and check the Reverse is False, so that the conditions are reversly applied i.e. if state !=new
Thanks!
Monica
ServiceNow | Everything as a Service
Please hit Like/Helpful/Correct if applicable.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2016 03:59 AM
FYI - That happens by default when you use an unscripted UI policy. When given the choice, I'll always take the unscripted solution (although I won't always remember that option at first.)