Slow performance reference qualifier script include

rai5
Mega Guru

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(',');
}

 

 

1 ACCEPTED SOLUTION

Jon Barnes
Kilo Sage

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:

 

find_real_file.png

View solution in original post

8 REPLIES 8

Jon Barnes
Kilo Sage

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:

 

find_real_file.png

Thanks Jon, that function worked.

Thanks Jon, its working absolutely fine. 

SanjivMeher
Kilo Patron
Kilo Patron

You can use the simple reference qualifier and use filter as Class is Application or Computer or Printer etc.

 

find_real_file.png


Please mark this response as correct or helpful if it assisted you with your question.