Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Populate list of child values from relationship table filtering condition in name of catalog

DhanashriP
Tera Contributor

Hi 

 

I want to Populate list of child values from relationship (cmdb_rel_ci) table filtering condition ()in "vm name" variable of catalog item, which is reference field refers to "cmdb_ci_vmware_instance" table(this is referring to the instance table because I want to filter all the vm name which has relationship where type is "Provides storage for::Stored on " and Parent does  not contains Placeholder).

I have tried using Script include and called the same in "vm name" variable's reference qual as "javascript:getvm()".

this is not working looking for help.

Script include:

 

var getVM = Class.create();
getVM.prototype = {
    initialize: function() {},
    getVM: function() {
        gs.log("In function");
        var option = [];
       var nameArray = [];
        var flag = new GlideRecord('cmdb_rel_ci');
        flag.addEncodedQuery('parentNOT LIKEPLACEHOLDER^type!=c6fd799338a02000c18673032c71b81d');
        flag.query();
        while (flag.next()) {
            option.push(flag.getDisplayValue('child'));
        }
        gs.log("childArrya"+ option);
       var vmwareResponse = new GlideRecord('cmdb_ci_vmware_instance');
        vmwareResponse.addQuery('name', 'IN', option);
        vmwareResponse.query();
        while (vmwareResponse.next()) {
            nameArray.push(vmwareResponse.name.toString());
        }
        return nameArray;

    },
    type: 'getVM'
};

DhanashriP_0-1723532202517.pngDhanashriP_1-1723532272996.png

 

0 REPLIES 0