- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2018 07:01 PM
Hello Devs,
I had to use a script include on a reference qualifier for the configuration item field on the task table due to limitations with the condition builder. The condition builder does not allow me to use as many filters and conditions as I need. The script include works fine but it is painfully slow. Is there a way to improve performance in this situation. I would imagine this is a very common challenge but I was not able to find anything while researching online.
here is the logic of the script. Feel free to suggest a better way.
function returncis() {
var objs = [];
var equery
= "sys_class_nameINcmdb_ci_computer,cmdb_ci_printer,cmdb_ci_ip_firewall,cmdb_ci_ip_router,cmdb_ci_ip_switch,cmdb_ci_wan_accel_network,cmdb_ci_ups,cmdb_ci_ucs_equipment,cmdb_ci_lb_netscaler,cmdb_ci_win_server,cmdb_ci_linux_server,cmdb_ci_solaris_server,cmdb_ci_unix_server,cmdb_ci_aix_server,cmdb_ci_storage_switch,cmdb_ci_db_mssql_instance,cmdb_ci_db_ora_instance^install_status!=7^discovery_sourceINManual Entry,ServiceNow,SolarWinds^EQ";
var ci = new GlideRecord('cmdb_ci');
ci.addEncodedQuery(equery);
ci.query();
while(ci.next()) {
objs.push(ci.getValue('sys_id'));
}
return 'sys_idIN' + objs.join(',');
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2018 07:10 PM
So the problem is that you are adding an extra query to the cmdb_ci table that you don't actually need. instead of what you have, can you try it with this function:
function returncis() {
return "sys_class_nameINcmdb_ci_computer,cmdb_ci_printer,cmdb_ci_ip_firewall,cmdb_ci_ip_router,cmdb_ci_ip_switch,cmdb_ci_wan_accel_network,cmdb_ci_ups,cmdb_ci_ucs_equipment,cmdb_ci_lb_netscaler,cmdb_ci_win_server,cmdb_ci_linux_server,cmdb_ci_solaris_server,cmdb_ci_unix_server,cmdb_ci_aix_server,cmdb_ci_storage_switch,cmdb_ci_db_mssql_instance,cmdb_ci_db_ora_instance^install_status!=7^discovery_sourceINManual Entry,ServiceNow,SolarWinds^EQ";
}
In fact, you can just put that string qualifier directly in the Advanced Ref Qualifier box on the task.cmdb_ci dictionary entry and don't really need the script include at all. like this:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2018 07:10 PM
So the problem is that you are adding an extra query to the cmdb_ci table that you don't actually need. instead of what you have, can you try it with this function:
function returncis() {
return "sys_class_nameINcmdb_ci_computer,cmdb_ci_printer,cmdb_ci_ip_firewall,cmdb_ci_ip_router,cmdb_ci_ip_switch,cmdb_ci_wan_accel_network,cmdb_ci_ups,cmdb_ci_ucs_equipment,cmdb_ci_lb_netscaler,cmdb_ci_win_server,cmdb_ci_linux_server,cmdb_ci_solaris_server,cmdb_ci_unix_server,cmdb_ci_aix_server,cmdb_ci_storage_switch,cmdb_ci_db_mssql_instance,cmdb_ci_db_ora_instance^install_status!=7^discovery_sourceINManual Entry,ServiceNow,SolarWinds^EQ";
}
In fact, you can just put that string qualifier directly in the Advanced Ref Qualifier box on the task.cmdb_ci dictionary entry and don't really need the script include at all. like this:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2018 08:10 AM
Thanks Jon, that function worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2020 02:46 AM
Thanks Jon, its working absolutely fine.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2018 07:14 PM