The Zurich release has arrived! Interested in new features and functionalities? Click here for more

List Collector Ignores Reference Qualifier – Script Include Not Working?

Erica2
Tera Contributor

Hellow,

 

I'm currently trying to learn how to properly call a Script Include from a List Collector variable's Reference Qualifier.

 

However, it seems that the list still returns data regardless of whether the Reference Qualifier is calling the Script Include or not.

 

Could someone please review my code and let me know where I might have gone wrong? Thank you!

 

List Collector Variable:

Erica2_0-1758238499053.png

 

Script Include: - It should only return a few inactive records if it is working correctly.

 

var SoftwareName = Class.create();
SoftwareName.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    getSoftwareNameRefQual: function() {
        var gr = new GlideRecord('u_software_inventory');
        gr.addQuery('active', false);  // Only inactive records
        gr.query();

        var softwareNames = [];

        while (gr.next()) {
            var name = gr.getValue('u_software_name');
            if (name)
                softwareNames.push(name);
        }

        return softwareNames.join(',');
    },

    type: 'SoftwareName'
});

 

3 REPLIES 3

Rafael Batistot
Kilo Patron

Hi @Erica2 

Try this: 

function onLoad() {
  var myListCollector = g_list.get("<name_of_list_colector>");
  myListCollector.reset();
  myListCollector.setQuery('active=false');
}

 

https://www.servicenow.com/community/developer-forum/can-list-collectors-be-filtered-in-the-service-...

Sarthak Kashyap
Tera Expert

Hi @Erica2 ,

 

1st of all please try to call script include like this :

javascript&colon; new global.softwareName().getSoftwareNameRefQual();

 

2nd thing I made changes in your return statement please verify that

var SoftwareName = Class.create();
SoftwareName.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    getSoftwareNameRefQual: function() {
        var gr = new GlideRecord('u_software_inventory');
        gr.addQuery('active', false);  // Only inactive records
        gr.query();

        var softwareNames = [];

        while (gr.next()) {
            var name = gr.getValue('u_software_name');
            if (name)
                softwareNames.push(name);
        }

        return "nameIN"+softwareNames.join(',');
    },

    type: 'SoftwareName'
});

 

Please mark my answer correct and helpful if this works for you

Thanks,

Sarthak

javascript; new global.softwareName().getSoftwareNameRefQual();



Also make sure your script include is not client callable.