- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2017 06:37 AM
So far we have plenty incident tickets already existing in our instance. We don't want to deactivate any value from subcategory.
Just want to users could not see them from the drop down list.
I try to use client script - onChange - g_form.removeOption('subcategory','email') to implement this. But it doesn't work for the reference fields like subcategory..
Does anyone have any idea to implement this?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2017 09:10 PM
Hi Wei,
I have tried below and it works, let me try to explain in details if this helps. Created a column (Right Click on the list header then configure -> List Layout) on sys_choice table and then create a new column Choice Not Needed (true/false type) and set the value to true for the records which you don't want to display. Refer the screen shot below.
then create a script include with below code. You might need to fine tune the code based upon your field name.
var GetListValue = Class.create();
GetListValue.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getList : function()
{
var ids = [];
var gr = new GlideRecord('sys_choice');
gr.addQuery('dependent_value', current.u_category.value); //Considering category is also a reference field.
gr.addQuery('name', 'incident');
gr.addQuery('u_choice_not_needed', 'false');
gr.query();
while(gr.next())
ids.push(gr.sys_id.toString());
return 'sys_idIN' + ids;
},
type: 'GetListValue'
});
and then set the reference qualifier on subcategory field like below.
Result: It's displaying the value of subcategory for which Choice Not Needed is set to false

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2017 06:32 PM
Can we try in this way, let's create a field in sys_choice table (say Choice Not Needed and set it to true for the records which we don't want to shoe them any more) and then have the advanced reference qualifier to filter out choices based upon the Choice Not Needed value and display accordingly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2017 06:44 PM
let me try this solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2017 07:46 PM
could you give detail step for your solution???

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2017 08:05 PM
Hello Wei,
I haven't tried or tested but was thinking this might give you some idea. Below is the sample script include which we can create.
var GetListValue = Class.create();
GetListValue.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getList : function()
{
var ids = [];
var gr = new GlideRecord('sys_choice');
gr.addQuery('dependent_value', current.category);
gr.addQuery('u_choice_not_needed', false);
gr.query();
while(gr.next())
ids.push(gr.sys_id.toString());
return 'sys_idIN' + ids;
},
type: 'GetListValue'
});
and then call the JavaScript in subcategory dictionary's reference qualifier. Please find the details here: Reference Qualifiers - ServiceNow Wiki
javascript:new GetListValue().getList()

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2017 09:10 PM
Hi Wei,
I have tried below and it works, let me try to explain in details if this helps. Created a column (Right Click on the list header then configure -> List Layout) on sys_choice table and then create a new column Choice Not Needed (true/false type) and set the value to true for the records which you don't want to display. Refer the screen shot below.
then create a script include with below code. You might need to fine tune the code based upon your field name.
var GetListValue = Class.create();
GetListValue.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getList : function()
{
var ids = [];
var gr = new GlideRecord('sys_choice');
gr.addQuery('dependent_value', current.u_category.value); //Considering category is also a reference field.
gr.addQuery('name', 'incident');
gr.addQuery('u_choice_not_needed', 'false');
gr.query();
while(gr.next())
ids.push(gr.sys_id.toString());
return 'sys_idIN' + ids;
},
type: 'GetListValue'
});
and then set the reference qualifier on subcategory field like below.
Result: It's displaying the value of subcategory for which Choice Not Needed is set to false