Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Restrict Configuration Item field to specific type

mhashemi
Mega Sage

I am working on a migration project which will bring CMDB and Knowledge Management to ServiceNow. As I look to re-create the article types from our current knowledge management application, I am trying to figure out if I can add a CI field, but only for a specific type of CI.

 

I have created a knowledge article template with my desired text fields, and the "Configuration item" field, but I cannot figure out how to have the searcher only show a subset of CIs. In this example, I have a list of "PC backup application" CIs, from which article authors should be able to select.

 

Can this be done? Thanks.

2 REPLIES 2

Not applicable

Add reference field to Knowledge article form, referencing cmdb_ciXXX, XXX being whatever class of CI you want available. Or, reference cmdb_ci and use filter criteria.

iamlamba
Tera Contributor

// This is a sample script, adjust it based on your CMDB structure and criteria
(function executeRule(current, previous /*null when async*/) {

// Define the criteria to filter CIs
var filterCriteria = "u_category=PC Backup Application";

// Use GlideRecord to filter CIs
var ciGr = new GlideRecord('cmdb_ci');
ciGr.addEncodedQuery(filterCriteria);
ciGr.query();

// Build a comma-separated list of CI sys_ids
var sysIds = [];
while (ciGr.next()) {
sysIds.push(ciGr.getUniqueValue());
}

// Set the reference qualifier
current.addQuery('sys_id', 'IN', sysIds.join(','));

})(current, previous);