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.

Reference qualifier is showing only one value

Kumar147
Tera Contributor

Hello,

I am calling script include in reference qualifier and i am getting only one value, instead of showing related values.

script include i am using:

 

    platform: function() {
        var app = current.cmdb_ci.getValue();
        var gr = new GlideRecord('u_rm_data_management');
        gr.addEncodedQuery('u_active=true^u_type=Choice^u_item=App Platform^u_applicationsLIKE' + app);
        gr.query();
        var result = [];
        while (gr.next()) {
            result.push(gr.sys_id.toString());
            return 'sys_idIN' + result.join(',');
        }
    },
 
adv ref qual condition: javascript: new scriptinclude().fucntion();
 
Please help in this.
20 REPLIES 20

Moin Kazi
Kilo Sage
Kilo Sage

Hi @Kumar147 ,

 

Typo error during calling script include in reference qualifier : 

adv ref qual condition: javascript: new scriptinclude().platform();

 

And put return statement outside while loop.

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you found my response **helpful**, I’d appreciate it if you could take a moment to select **"Accept as Solution"** and **"Helpful"** Your support not only benefits me but also enriches the community.

 

Thank you!
Moin Kazi
www.linkedin.com/in/moinuddinkazi

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Hello @Moin Kazi 

I tried that but no luck

what is your script include name and please share pic how you called it in reference qualifier?

Hello @Moin Kazi 

Script include name is appapplication and please find the picture of that.

Kumar147_0-1730207425533.png

 

Hi @Kumar147 ,

 

You cannot use the current object inside a Script Include without passing it as a parameter to your function.

 

Please pass the current object to your function as shown below:

javascript: new appapplication().platform(current.getValue('cmdb_ci'))

 

And structure your Script Include like this:

 

platform: function(app) {
        var gr = new GlideRecord('u_rm_data_management');
        gr.addEncodedQuery('u_active=true^u_type=Choice^u_item=App Platform^u_applicationsLIKE' + app);
        gr.query();
        var result = [];
        while (gr.next()) {
            result.push(gr.sys_id.toString());
        }
        return 'sys_idIN' + result.join(',');  
    },