The Now Platform® Washington DC release is live. Watch now!
So you've worked hard getting your CMDB populated with all the objects that should fall under configuration management and/or be part of your service management processes like incident, problem, and change. It is very likely that you now have hundreds, thousands, or even millions of CI's from which to choose when you are handling an incident or performing a change. How can a user reasonably sort through them and choose the correct one?
While there are many strategies for creating filters in ServiceNow, in this short article I hope to provide an example of how you can use advanced reference qualifiers on forms like incident or problem to narrow the available list of CI's so that the appropriate item is selected and tracked through its lifecycle.
The process requires the following 2 steps:
Step 1 - Create script include
Script Include Definition
Below is sample code that can be used for the script include to take a parameter of the current record and then evaluate the category value to create the filter. Adjustments to the category switch will be required to match the categories used within your own organization.
var RefQualUtils = Class.create();
RefQualUtils.prototype = {
initialize: function() {
},
getCIRefQual : function() {
var filter = 'sys_class_nameINSTANCEOFcmdb_ci^operational_status=1';
var cat = current.category + '';
switch(cat) {
case 'software':
filter = "sys_class_nameINSTANCEOFcmdb_ci_appl^operational_status=1";
break;
case 'hardware':
filter = "sys_class_nameINSTANCEOFcmdb_ci_hardware^operational_status=1";
break;
case 'network':
filter = "sys_class_nameINSTANCEOFcmdb_ci_netgear^operational_status=1";
break;
case 'database':
filter = "sys_class_nameINSTANCEOFcmdb_ci_db_instance^operational_status=1";
break;
default:
filter = "sys_class_nameINSTANCEOFcmdb_ci^operational_status=1";
break;
}
return filter;
},
type: 'RefQualUtils'
};
Code Sample for Reference Qualifier
It is useful to note that the "INSTANCEOF" qualifier is needed if you want the define class and all of its child classes. If you only set the class name to a specific class, then you will only get CIs within that one class. One easy way to update the encoded queries used in the example is to open the list of CI (cmdb_ci.LIST in the filter navigator), and then create your own filter to show what you want for a given category. Once you have the filter defined, just right-click on the right-most breadcrumb of the filter definition and choose "Copy query". You should then be able to paste it into the script include and have it applied as the filter for that category.
Step 2 - Define a dictionary override
The steps for specifying the reference qualifier may differ depending on your preference for navigating to the dictionary entry, but the following steps are based on how I get there using a Kingston instance. First, open the table definition for the incident table and find the Column Name cmdb_ci. When you open that record, you should be taken to the Dictionary Entry for configuration item.
Dictionary Entry for Configuration Item
Notice how the table reference changes to "Task" because incident is extended from class. We do NOT want to change the Reference Qualifier definition as it exists on the task table, so we need to scroll down to the related lists and defined a dictionary override.
Dictionary Overrides on Task Table
You will likely need to create a New override for the incident table (the screenshot above has already done this). Once in the New definition, simply choose the parameters as noted below and paste in the code sample provided.
Override the Reference Qualifier for the Incident table
This code sample is what is noted in the screenshot and calls our previously defined script include and passes in the current record for evaluation.
javascript: new RefQualUtils().getCIRefQual(current);
That's it! You can now test the functionality by going to the incident form, choose a category, then choose the configuration item explorer, and watch the available CIs change as you change the category type.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.