- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 12:16 PM
Dear,
I'm busy with creating a new Catalog Item. I first create a variable called 'Service_Catalog' where I'm asking the enduser to select one of the existing Service Catalogs (sc_catalog.list). Now I like that the end user selects in a second variable called 'Catalog' only one category of the existing categories of the Service Catalog selected in the previous variable (Service_Catalog). I know I need to use a Reference Qualifier but I have no knowledge about Java scripting. Can someone help me in telling me how I can show in the variable 'Categorie' only the Categories that belongs to the Service Catalog entere in the variable 'Service Catalog'.
Many thanks for helping me out.
-Jo-
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 01:12 PM
Hi @JoSte ,
you can create a script include and call that script include through reference qualifier as shown below,
on the field 'Catalog' go to advanced reference qualifier and add below code
javascript: new getServiceCatalog().getCategories(current.variables.service_catalog);
In script include try :
var getServiceCatalog = Class.create();
getServiceCatalog.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getCategories: function(serviceCategories) {
var arr = [];
var gr = new GlideRecord('sc_category');
gr.addQuery('sc_catalog', serviceCategories);
gr.query();
while(gr.next())
{
arr.push(gr.sys_id.toString());
}
return 'sys_idIN'+ arr.toString();
},
type: 'getServiceCatalog'
});
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2024 01:12 PM
Hi @JoSte ,
you can create a script include and call that script include through reference qualifier as shown below,
on the field 'Catalog' go to advanced reference qualifier and add below code
javascript: new getServiceCatalog().getCategories(current.variables.service_catalog);
In script include try :
var getServiceCatalog = Class.create();
getServiceCatalog.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getCategories: function(serviceCategories) {
var arr = [];
var gr = new GlideRecord('sc_category');
gr.addQuery('sc_catalog', serviceCategories);
gr.query();
while(gr.next())
{
arr.push(gr.sys_id.toString());
}
return 'sys_idIN'+ arr.toString();
},
type: 'getServiceCatalog'
});
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang