Variable attributes for list collector on cmdb_group_contains_ci

ILYA STEIN
Tera Guru

I have a list collector on cmdb_group_contains_ci table. The display column defined for the table is 'group', so the list properly displays group names. However, I need to make this list a dependency of another selector that will select a group, and have the list display configuration items of the selected group instead. This is what I have in the list collector's Type Specification tab:

ILYASTEIN_1-1737498623174.png

 

The dependency part works, however, the list still displays group name for each configuration item instead of the configuration item name. Both configuration_item and group are reference fields. What am I missing?
Pasting the actual Variable attributes string here for reference:
ref_auto_completer=AJAXTableCompleter,ref_ac_columns=configuration_item,ref_ac_columns_search=true,ref_ac_display_value=false,ref_qual_elements=select_ci_group
P.S. I understand I can change display value for the table to be configuration_item rather than group, but I don't want to break any existing functionality that relies on the existing definitions.

 

1 ACCEPTED SOLUTION

Thank you, Ankur. I looked at some community examples and was under the wrong impression that it's possible to accomplish what I wanted by using Variable attributes and without changing the display value in the dictionary. Since this is not possible, I came up with a different solution, which I am explaining below in case someone else has a similar need.
1. In the list collector, instead of configuring List Table as cmdb_group_contains_ci, configure it as cmdb_ci (configuration item). In general, this approach should work for any reference field, by specifying the referenced table.
2. Create a server-side script include with a function to return the filter to be used to retrieve configuration items for the selected group. This involves two steps:
2a) Retrieve the selected group's CIs from the cmdb_group_contains_ci table:

    var gr_rel_group_ci = new GlideRecord('cmdb_group_contains_ci');
    gr_rel_group_ci.addEncodedQuery('group=' + select_ci_group.toString());
    gr_rel_group_ci.query();
    var ci_array = [];
    while (gr_rel_group_ci.next()) {
        ci_array.push(gr_rel_group_ci.configuration_item.toString());
    }

2b) Use the selected CIs' sys_ids to return a query for cmdb_ci table: 'sys_idIN'+<list of IDs>:
   return 'sys_idIN' + ci_array.join(',');

3. Invoke the above function in the list collector's Reference qualifier: javascript&colon; (new GroupMembership).ciSelect()
4. Add your selection criteria to the Variable attributes field, e.g.: ref_qual_elements=select_ci_group
This solution is fully independent of how display attribute is set in the group membership table, and uses a script include to properly filter configuration items from cmdb_ci.

 

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@ILYA STEIN 

after selecting the value it will always show the field value which is marked as Display=true on that table.

No other way to handle this

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Thank you, Ankur. I looked at some community examples and was under the wrong impression that it's possible to accomplish what I wanted by using Variable attributes and without changing the display value in the dictionary. Since this is not possible, I came up with a different solution, which I am explaining below in case someone else has a similar need.
1. In the list collector, instead of configuring List Table as cmdb_group_contains_ci, configure it as cmdb_ci (configuration item). In general, this approach should work for any reference field, by specifying the referenced table.
2. Create a server-side script include with a function to return the filter to be used to retrieve configuration items for the selected group. This involves two steps:
2a) Retrieve the selected group's CIs from the cmdb_group_contains_ci table:

    var gr_rel_group_ci = new GlideRecord('cmdb_group_contains_ci');
    gr_rel_group_ci.addEncodedQuery('group=' + select_ci_group.toString());
    gr_rel_group_ci.query();
    var ci_array = [];
    while (gr_rel_group_ci.next()) {
        ci_array.push(gr_rel_group_ci.configuration_item.toString());
    }

2b) Use the selected CIs' sys_ids to return a query for cmdb_ci table: 'sys_idIN'+<list of IDs>:
   return 'sys_idIN' + ci_array.join(',');

3. Invoke the above function in the list collector's Reference qualifier: javascript&colon; (new GroupMembership).ciSelect()
4. Add your selection criteria to the Variable attributes field, e.g.: ref_qual_elements=select_ci_group
This solution is fully independent of how display attribute is set in the group membership table, and uses a script include to properly filter configuration items from cmdb_ci.