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

Thanks for the response.  Can you please mark my answer from above as the correct answer if I've answered your question?  Thanks!

yoed_b
Giga Contributor

Daniel, Mark - It's a great solution!  True magic indeed.

 

However i'm running into same problem like Daniel - the Performance. Like any Query BR, is not good (server - about 4500).

The query we used is simple  - we just added a u_customer field (true/false) and indexed it, to sys_db_object.

 

Again - this works great, but have you guys found a different way for this minus the performance issue?  Perhaps in the script include: AssociateCIToTask ?

tillu
Giga Expert

Hi all,

The display is that of a UI Page. That UI Page has its own logic to build the list. Add the filters to that logic.

 

 

Hi Tillu,

Would you know which UI Page? currently i have it when they click the Add button it puts in a fix query so the user can not change it however if they change the Configuration class from lets say Network to Security that wipes out my query and shows them all configuration items for all companies. We are trying to limit what CI they see based on the company of the selected change.

Hello Efren,

Sorry for the late reply. I think, in your case, it would be easier to go down the route of updating the script include  AssociateCIToTask > function get URL, and include the extra filters.