- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2025 09:55 AM
We wants to achieve reference qualifier for configuration Item variable based on two conditions:
1. if category selected as software it should show the records from table - cmdb_ci_service_discovered and cmdb_ci_service_auto.
(For this we have wrote advance qualifier , it is working fine -
javascript:current.variables.category=='software' ? 'sys_class_name=cmdb_ci_service_discovered^ORsys_class_name=cmdb_ci_service_auto' : '' )
2. The field CI on the RRP should only show records from Primary classes.
In backend, on incident we have reference qualifier For CI - javascript: ['incident', 'problem'].indexOf(current.sys_class_name + '') == -1? '' : 'operational_statusNOT IN' + new OpsStatusFilter('cmdb_ci').by('CreateTask').join()
How can we achieve this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2025 10:08 AM
Got the solution -
javascript:current.variables.category == 'software' ? 'sys_class_name=cmdb_ci_service_discovered^ORsys_class_name=cmdb_ci_service_auto' : new TaskUtils().getConfigurationItemFilter({sys_class_name : 'incident'})
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2025 07:58 AM
Hi we have second condition as if category is not software than CI should show principle classes CI's
We already have script include in system that we are using for CI on Incident form.
SI -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2025 08:19 AM
Hi @Pratiksha KC ,
you can put the script I have shared in the refence qualifier
this script include OpsStatusFilter.by method is only returns operational status of CIs which should not be available for selection that's it. it has nothing to do with principal classes
principle class ci are the classes of cis
to find principal class you can go to table cmdb_class_info table and find where principal class is true
I have tested this script and is working try this
javascript:(function() {
if (current.variables.category == 'software')
return 'sys_class_name=cmdb_ci_service_discovered^ORsys_class_name=cmdb_ci_service_auto';
var cciGr = new GlideRecord("cmdb_class_info");
cciGr.addEncodedQuery("principal_class=true");
cciGr.query();
var clssArr = [];
while (cciGr.next()) {
clssArr.push(cciGr.getValue('class'));
}
return '^operational_statusNOT IN' + new OpsStatusFilter('cmdb_ci').by('CreateTask').join() + (clssArr.length ? '^sys_class_nameIN' + clssArr.join() : '');
})();
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2025 02:24 AM
so the 1st requirement is done
what's the 2nd one?
are you saying if it's software then 1st filter and if not software then the 2nd filter should come as per INC ref qualifier?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2025 02:28 AM - edited 06-12-2025 02:34 AM
Yes, if category is not software , it should show records from Primary classes.
(As same RQ as we have in backend for incident : javascript: ['incident', 'problem'].indexOf(current.sys_class_name + '') == -1? '' : 'operational_statusNOT IN' + new OpsStatusFilter('cmdb_ci').by('CreateTask').join() )
Also we are facing issue with CI variable showing duplicate CIs.
we wants to restrict duplicate CI's name from the Configuration item.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2025 02:33 AM
this line simply gives you the choice value for operational status
why not use directly?
var val = new OpsStatusFilter('cmdb_ci').by('CreateTask').join();
gs.info(val);
This prints 6 which is the choice value for operational status field
So update your advanced ref qualifier as this
javascript: var query; if(current.variables.category == 'software') query = 'sys_class_name=cmdb_ci_service_discovered^ORsys_class_name=cmdb_ci_service_auto'; else query = 'operational_statusNOT IN6'; query;
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader