
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2017 11:52 PM
Hi All,
I want to remove the choice in the state field for an ITIL user.
My Requirement.
If state is new : All choices should display.
If In progress: Display only In progress, Cancelled, On hold.
If On Hold: Resolved,In progress, cancelled.
Can any one help me .
ServiceNow Commnunity MVP -2018 class.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2017 12:12 AM
Hello Karthik,
This can be done via Client script. Based on the condition you have to add or remove the choice values. Please refer.
http://wiki.servicenow.com/index.php?title=GlideForm_(g_form)#gsc.tab=0

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2017 12:12 AM
Hello Karthik,
This can be done via Client script. Based on the condition you have to add or remove the choice values. Please refer.
http://wiki.servicenow.com/index.php?title=GlideForm_(g_form)#gsc.tab=0

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2017 12:25 AM
Thanks Pradeep,
Its working now.
ServiceNow Commnunity MVP -2018 class.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2017 12:20 AM
Hello
i hope this could be helpful :
removeOption
void removeOption(fieldName, choiceValue)
- Removes a specific option from a choice list.
- Note: (Versions prior to Eureka) When items are removed from a choice list by a Client Script, Google Chrome and Apple Safari will still display those items. When one of these web browsers is used, the "removed" items will be displayed as read only in the choice list and they cannot be chosen.
- Parameters:
- fieldName - specifies the field.
- choiceValue - specifies the value stored in the database as a choice.
- Returns:
- void
- Example: Remove the '1' Option from the Priority Field
g_form.removeOption('priority', '1');
- Example: Remove the 'Closed' State Option if the User is not an Admin
function onLoad() { var isAdmin = g_user.hasRole('admin');
var incidentState = g_form.getValue('incident_state');
if (!isAdmin && (incidentState != 7)){ g_form.removeOption('incident_state', '7'); } }
Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2017 12:26 AM
Hi Karthik,
You want to set the state field based upon the state field value? that can be done with onChange() client script,
How about this condition If On Hold: Resolved,In progress, cancelled. ??
Something like this should help,
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
if(g_user.hasRole('admin'))
{
if(g_form.getValue('state') == '2')
{
g_form.clearOptions('state');
g_form.addOption('state', '2');
g_form.addOption('state', '3');
g_form.addOption('state', '8');
}
}
}