Configuration Items based on Category&Sub-Category
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2015 12:41 PM
I am trying to limit the Configuration Item list to a specific few that depend on Category and Sub-Category.
When I choose a Category and corresponding Sub-category, In the CI field, I want only certain CIs to be in the drop down.
How can I do this?
I notice that some of my CIs don't even have a Category section when I go to create a new one.
- Labels:
-
Scripting and Coding
-
Team Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2015 04:23 AM
Hi Sam,
Best way is to use script include as suggested by Micheal making it flexible for any future changes.
Just a small modification in Micheal's code. I feel using array makes it more easier.-
function catsubcat() {
if (current.category == '' || current.subcategory == '') {
return;
}
else {
var sysIDArray = [];
var retval = "sys_idIN";
}
gs.log('both are populated');
var ci = new GlideRecord ('cmdb_ci');
ci.addQuery('category', current.category);
ci.addQuery('subcategory', current.subcategory);
ci.query();
while (ci.next()) {
sysIDArray.push(ci.sys_id.toString());
//retval += ci.sys_id + ",";
}
return retval+sysIDArray.join(',');
}
For more help please check-
Advanced Reference Qualifier Using a Script Include - ServiceNow Guru
Reference Qualifiers - ServiceNow Wiki
Thanks,
Tanaji Patil
--Mark correct/helpful if it helps solving your issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-01-2015 11:32 AM
is your Question Answered?? please let us know.
i am curious to know are you working on incident Application. if yes, you can use Ref Qual as "category=current.category^subcategory=current.subcategory^EQ .
simplest way is to use Above code. But i am doubtful about you can limit CI record based on Category and Subcategory.
Thanks & Regards
govind Kumar Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-01-2015 11:34 AM
Hi Sam,
Please confirm if your requirement fulfilled . if no I have few Suggestions for you.
Thanks & Regards
Govind Kumar Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-01-2015 12:16 PM
var catsubcat = Class.create();
catsubcat.prototype = {
initialize: function() {
},
type: 'catsubcat'
};
if (current.category == '' || current.subcategory == '') {
return;
}
else {
var sysIDArray = [];
var retval = "sys_idIN";
}
gs.log('both are populated');
var ci = new GlideRecord ('cmdb_ci');
ci.addQuery('category', current.category);
ci.addQuery('subcategory', current.subcategory);
ci.query();
while (ci.next()) {
sysIDArray.push(ci.sys_id.toString());
//retval += ci.sys_id + ",";
}
return retval+sysIDArray.join(',');
It gives me an error when I try to make this Script Include.
Maybe I'm typing it in wrong.