How can I autopopulate configuration item based on category and subcategory on the incident form?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2023 07:40 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2023 11:33 AM
Hello @Ria ,
If there is a relationship between cmdb_ci and the incident categories, this can be done. I don't believe the cmdb_ci categories correspond to the incident categories.
1. Use client callable script include to look up a Configuration Item (CI) based on category and subcategory and return the CI sys_id.
Client Callable Script Include:
var CILookup = Class.create();
CILookup.prototype = {
initialize: function () {},
getCI: function (category, subcategory) {
var ciGr = new GlideRecord('cmdb_ci');
ciGr.addQuery('category', category);
ciGr.addQuery('subcategory', subcategory);
ciGr.query();
if (ciGr.next()) {
ciSysId = ciGr.getValue('sys_id');
}
return ciSysId;
},
type: 'CILookup'
};
Client Script with GlideAjax:
function onChange() {
var category = g_form.getValue('category_field');
var subcategory = g_form.getValue('subcategory_field');
var ga = new GlideAjax('CILookup');
ga.addParam('sysparm_name', 'getCI');
ga.addParam('sysparm_category', category);
ga.addParam('sysparm_subcategory', subcategory);
ga.getXML(function (response) {
var answer = response.responseXML.documentElement.getAttribute('answer');
if (answer) {
g_form.setValue('ci_field', answer);
}
});
}
OR
You can set this with reference qualifiers if you have a relationship:
javascript: 'category=' + current.category.getDisplayValue() +'^subcategory='+current.subcategory.getDisplayValue();
And please refer to this also: https://www.servicenow.com/community/itsm-forum/based-on-category-and-subcategory-populate-configura...
@Ria, Please mark my answer as "Accept as Solution" and "Helpfuls." If it works for you.
Thank You!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2023 12:30 AM
Hi Khushboo,
We don't have any relationship between cmdb_ci and the incident categories. Is there any other way to achieve this?
Thank you!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2023 12:42 AM
Hello Riya,
If there is no relation, then it will only be possible if you have the same subcategory and category choices in both the cmdb_ci table and the incident table.
Otherwise, you need to hardcode the sys_ids of the CI in the code, but this is not a feasible solution.
Thanks!