having 2 list collector variables 2nd variables values dependent upon first

keshav77
Tera Contributor

I am having 2 variables 1st variable holding the parent ci value and I want to populate child ci value depend upon 1st ci variable value..

 

here is the script include which I written--

var BAI_RelatedListFilter = Class.create();
BAI_RelatedListFilter.prototype = {
    initialize: function() {
    },
 cidetails:function(applications) {

    var result = [];
        var grci = new GlideRecord('cmdb_rel_ci');
        grci.addEncodedQuery("child.sys_class_name=u_cmdb_busapp_instance^parent.sys_class_name=cmdb_ci_business_app");
        grci.addQuery('parent','IN', applications);

        grci.query();
        while (grci.next()) {
            result.push(grci.child.toString());
        }
        return result.toString();
    },
    type: 'BAI_RelatedListFilter'
};
keshav77_0-1726163808364.pngkeshav77_1-1726163870856.png

 

help me with this
   
   
2 ACCEPTED SOLUTIONS

Brad Bowman
Kilo Patron
Kilo Patron

Is the 1st variable named 'applications' or is that the name of the 2nd list collector variable?  Be sure to add ref_qual_elements=applications to the Variable attributes (append to the end after a comma) so that the list filter updates when the applications variable value changes.

In the Script Include, you need to return like this

return 'sys_idIN' + result.join(',');

or result.toString() will probably work too, but since you want it to be comma-separated, better to explicitly specify that.

View solution in original post

Why did you abandon the previous reference qualifier?  Your current one is being ignored because it's invalid.  You can filter on only CIs in the u_cmdb_busapp_instance class, if your requirements have changed and it doesn't matter if those CIs have a relationship with any other CIs, but adding the result of the first variable to the end of this without specify a field on the list table and an operation (IN since the first variable is a list collector) is invalid.

View solution in original post

3 REPLIES 3

Brad Bowman
Kilo Patron
Kilo Patron

Is the 1st variable named 'applications' or is that the name of the 2nd list collector variable?  Be sure to add ref_qual_elements=applications to the Variable attributes (append to the end after a comma) so that the list filter updates when the applications variable value changes.

In the Script Include, you need to return like this

return 'sys_idIN' + result.join(',');

or result.toString() will probably work too, but since you want it to be comma-separated, better to explicitly specify that.

this is not working for me  2nd variable don't show any values in it. even though I try to use--javascript:"sys_class_name=u_cmdb_busapp_instance^EQ"+current.variables.applications 

as qualifier value and ref_qual_elements=applications in attributes as well.

it shows all ci's values rather the dependent value of 1st variable

Why did you abandon the previous reference qualifier?  Your current one is being ignored because it's invalid.  You can filter on only CIs in the u_cmdb_busapp_instance class, if your requirements have changed and it doesn't matter if those CIs have a relationship with any other CIs, but adding the result of the first variable to the end of this without specify a field on the list table and an operation (IN since the first variable is a list collector) is invalid.