The CreatorCon Call for Content is officially open! Get started here.

Filter the Configuration Class in the Add Affected CIs overlay for Change

Daniel Peel
Mega Sage

So I need to filter this reflist.

find_real_file.png

Does anyone know where I can filter this?  We only use a few of the classes and I don't want users select the wrong ones.  They will be empty.... but it would lead to confusion if they still 600 classes ... when we only use about 15 for now.  

 

this is url that the link brings up

<a id="lookup.child_table_field" tabindex="-1" class="icon-search btn btn-default sn-tooltip-basic" title="Lookup using list" onclick="mousePositionSave(event);reflistOpen( 'child_table_field', 'not', gel('child_table_fieldTABLE').value, '', 'false', 'QUERY:super_class.nameINSTANCEOFcmdb_ci^ORname=cmdb_ci', 'super_class.nameINSTANCEOFcmdb_ci^ORname=cmdb_ci', '')"><span class="sr-only">Lookup using list</span></a>

 

I found references to reflistOpen in some templates... but not where to pass filters into it.  

thanks for any help

1 ACCEPTED SOLUTION

Mark Stanger
Giga Sage

There's no way to get to that filter directly to modify it, so you have to detect (and modify) the query that returns those values.  You should be able to accomplish this with a business rule on the 'sys_db_object' table.  The business rule will have a 'When' value of 'Before' and the 'Query' checkbox checked.  It will identify this specific query and then restrict it a bit further with your own custom encoded query to return just the CI types you want.  You should just have to set this up and then add your own encoded query with your CI types.  The included script here shows you how you could restrict this to Server and Business Service CIs.  Here is the script...

(function executeRule(current, previous /*null when async*/) {
	// Adjust the list of CI classes returned in 'Add' CI dialog
	// Get URL parameter values so we can identify just this query
	var qual = RP.getParameterValue('sysparm_additional_qual');
	var target = RP.getParameterValue('sysparm_target');
	
	// If we find a match restrict the query
	if (qual.indexOf('cmdb_ci') > -1 && target == 'child_table_field') {
		// Add custom encoded query for the 'sys_db_object' table here
		current.addEncodedQuery('super_class.nameINSTANCEOFcmdb_ci_server^ORname=cmdb_ci_service');
	}
	
})(current, previous);

View solution in original post

12 REPLIES 12

Jeff Schodde
ServiceNow Employee
ServiceNow Employee

Unfortunately that UI Page is not accessible according to this KB article:

https://hi.service-now.com/kb_view.do?sysparm_article=KB0713599

 

Sorry, seeing this only now. In a previous reply I specified what I did: "What I did is add the required filter as a parameter and then updated the script include AssociateCIToTask, function get URL, to include in the filters that is pulling the data."

tillu
Giga Expert

I looked up my work on this as I did the work some time ago. What I did is add the required filter as a parameter and then updated the script include AssociateCIToTask, function get URL, to include in the filters that is pulling the data.