Lookup select box not working as expected.

gjz1
Giga Expert

Hello,

I have a catalog item with a requirement to allow the user to add the CI that is impacted.  To meet this requirement I created two variables, a reference variable on sys_db_object to get the classes and a lookup select box variable to select the cmdb_ci based on the class selected in the first variable. For example, the user should be able to select "Server" (which is cmdb_ci_server) as the class to limit the CI (cmdb_ci) list to just records from cmdb_ci_server.

However, I'm having several issue with the lookup select box. 

1. It takes forever to load the catalog item form.  If I remove the configuration item variable it loads fine so I assume it has something to do with the number of rows in cmdb_ci.  Does a lookup select box always load all values when loading the form?  I don't want the configuration item variable to load any data until the "class" is picked in the 1st variable.

2. The configuration item variable doesn't appear to use the reference qualifier at all.  I added a logging row to verify it is calling the script include but I never see the log in the script log.

Because there isn't any class table (that I'm aware of) to select which cmdb_ci record you want I had to use sys_db_objects to get the "class" (the ci table name) in my first variable to use as a limit in the 2nd variable on the cmdb_ci table (ci table name from first variable = sys_class_name).  If anyone knows a better way to accomplish the same thing please let me know.

Here are my variables:

find_real_file.png

Class name variable:

find_real_file.png

Configuration item variable:

find_real_file.png

find_real_file.png

Script include:

getCIs: function(tableID,CIdata) {
// get the table name that was selected in the catalog
gs.log('### in ci function: ' + ci_table);
var cis = [];
var tbName = '';
var tb = new GlideRecord('sys_db_object');
tb.addQuery('label', ci_table);
tb.query();
while(tb.next()) {
tbName = tb.label;
gs.log('### table: ' + tbName);
}

// now search cmdb_ci to find all records that match the table name
var cmdb = new GlideRecord('cmdb_ci');
cmdb.addQuery('sys_class_name', tbName);
cmdb.query();
while(cmdb.next()) {
cis.push(cmdb.sys_id.toString());
}
if(CIdata)
cis.push(CIdata);
return 'sys_idIN'+cis.toString();

},

Catalog item:

find_real_file.png

The list isn't limited to servers:

find_real_file.png

6 REPLIES 6

Darn, it isn't what we need.  It is much faster but now I can't get the name, asset tag, etc. that is needed in the configuration item list - which is why it was set up as a lookup select box.

You can change the list view columns to add the required fields you want.

Or you can also add reference qualifier, for ex

ref_auto_completer=AJAXTableCompleter,ref_ac_columns=asset_tag;name

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