Export category and subcategory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2015 06:39 AM
Is there a way to export out the category and subcategory combinations into an excel file? for example
Category : Access - Sub category: A, B, C
Category : Hardware - Sub Category: D, E , F
Access | A
Access | B
Access | C
Hardware | D
Hardware | E
hardware | F
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2015 07:35 PM
https://myinstance.service-now.com/sys_choice.do?CSV&sysparm_default_export_fields=all
Run this in the address tab of browser. It will give you all the choice records.
You can then sort them with dependent value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2015 11:24 PM
Hi Sean, the following script should be able to do that for you.
var catChoice = new GlideRecord('sys_choice');
catChoice.addQuery('element','category');
catChoice.query();
while (catChoice.next()){
var subCats = [];
var subCatChoice = new GlideRecord('sys_choice');
subCatChoice.addQuery('dependent_value', catChoice.value);
catChoice.addQuery('element','subcategory');
subCatChoice.query();
while(subCatChoice.next()){
subCats.push(subCatChoice.value.toString());
}
gs.print (catChoice.value + '|' + subCats.join(','));
}
You can execute it from a background script. Just make sure you have security_admin role and that you have elevated your privileges.
I hope it is helpful!
Thanks,
Berny

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2021 09:58 AM
I found the following to be easier without needing to use a script.
Just open the Choices table as a list (sys_choice.list). Then I just filtered "Element" by "subcategory".
Doing it this way also allows you to use regular filter options and then exporting to Excel/CSV by right-clicking on the column names.