Restriction to Choice list for role
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2015 07:08 AM
Hi Experts,
I want to restrict the visibility/access to two or three choices in Drop down for Incident. Only certain users with particular role can access the choices/ edit them.
What will be approach please suggest.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2015 01:53 AM
Get the logged in user roles, if any of the role in your list to hide some choice values use removeOption(fieldName, choiceValue) method.
Methods to get the user roles: GlideUser (g user) - ServiceNow Wiki
Methods to add/remove choice values: GlideForm (g form) - ServiceNow Wiki

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2016 02:21 AM
Check the client Script "(BP) Hide Choice - Closed" on the incident form. That does exactly what you are looking for.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2019 04:10 AM
Sure. This example works fine.
Create a new Client Script that runs onLoad
This script hides the (custom) value integration from contact_type field.
function onLoad() {
//who to display it for - admin
var isAdmin = g_user.hasRole('admin');
//set up conditions to hide
if (!isAdmin){
g_form.removeOption('contact_type', 'integration');
}
}