- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2016 09:01 AM
Is there a script that can be place to remove options under a variable. UI Policy will just hide the variable and that's not what I want.
For example:
If Remove User Access is selected for Type:
I want only N/A to show and not the other 2 options for Ready Only or Write.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2016 10:39 AM
Here you go
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue== 'Remove User Access') {
g_form.removeOption('edit_or_read_only', 'Read Only');
g_form.removeOption('edit_or_read_only', 'Write');
}
else{
if(g_form.getOption('edit_or_read_only','Read Only')==null){
g_form.addOption('edit_or_read_only','Read Only','Read Only');
}
if(g_form.getOption('edit_or_read_only','Write')==null){
g_form.addOption('edit_or_read_only','Write','Write');
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2016 09:22 AM
That was my assumption based on the fact that you posted this in the Service Catalog space on the community and were referencing variables rather than fields.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2016 09:27 AM
So where in this script would I put the variable Type and Read Only and Write?
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (newValue === '') {
return;
}
if (g_form.getValue('type') == 'Remove User Access')) {
g_form.removeOption('additional_information', 'Read only');
g_form.removeOption('additional_information', 'Write');
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2016 09:30 AM
Your onChange client script would be set to watch the "Type" field.
That being said, this could be simplified slightly be doing this:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (newValue === '') {
return;
}
if (newValue== 'Remove User Access')) {
g_form.removeOption('additional_information', 'Read only');
g_form.removeOption('additional_information', 'Write');
}
}
newValue represents the choice changing select on the Type field to be "Remove User Access". If that is true, then the next two lines remove the Read only and Write options from the Additional information choice list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2016 09:38 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2017 09:04 AM
Hi Chuck,
Just wanted to confirm if there is any impact if you use the removeOption on a 'Reference' field or 'Type' = Select Box from a Catalog or Record Producer form (Incident, Change etc.). Will it also physically remove the option from the actual reference field of table since the field is being "reference to". Or does it use some type of copy /cache method on the actual form itself. Example, Category and Subcategory fields being reference from the Incident table. If options are removed with a client script on on the entry from, will the options be removed from the Incident table Category or Subcategory field(s) as well. Hope this makes sense?
If yes, what would be the workaround to re-add the options after the form has been submitted, so future forms will contain all the same options. Or just don't reference a field at all if option need to removed.
Thank you,
-Wesley