- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2018 04:04 PM
So I need to filter this reflist.
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
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2018 06:45 PM
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);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2018 05:11 AM
Thanks for the response. Can you please mark my answer from above as the correct answer if I've answered your question? Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2018 08:18 AM
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 ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2019 06:35 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2019 04:53 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2020 05:52 AM
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.