Filter a subcategory field from category field in Catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2019 01:31 PM
Hi all,
I have two reference fields in a catalog item (Category, subcategory). Both based on sys_choice table and they are the choices of the category and subcategory fields of the incidents table.
I need to filter the subcategory based on his dependent value field to link to the category field, like the categories and subcategories in the incident module.
Note: I've been trying with Reference Qualifier
Any help will be appreciated.
Thanks in advance
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2019 02:13 PM
You need to use advanced reference qualifier with script include for subcategory field.
Please check below
https://www.servicenowguru.com/scripting/script-includes-scripting/advanced-reference-qualifier-script-include/
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2019 02:14 PM
Also you need to write an Onchange client script along with the reference qualifier.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2019 02:34 PM
Since you indicated you are using reference fields, you should be able to make the following changes to your variables:
Category variable:
Reference qualifier: name=incident^element=category^inactive=false^ORDERBYsequence
Subcategory variable:
Reference qualifier: javascript:'name=incident^element=subcategory^inactive=false^dependent_value=' + current.variables.category + '^ORDERBYsequence';
Variable attributes: ref_qual_elements=category
I am guessing that your category variable name is category. If it is something different, change the ref_qual_elements accordingly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2019 03:19 PM
Hi,
Thanks for your reply.
I used both reference qualifiers that you bring me, but when I search the subcategory it doesn´t find records.
Note: I replaced category with the name of my variable in the subcatecory's reference qualifier and variable attributes
Thanks again.