The CreatorCon Call for Content is officially open! Get started here.

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'
});

 

2 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron
Tera Patron

@Erica2 

why you require script include?

what do you mean by few records? how many 5 or 10 or 100?

you can directly form the encoded query and copy paste there

javascript: 'u_active=false';

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

View solution in original post

Anand2799
Tera Guru

Hi @Erica2 ,

 

Based on your requirement you don't need a script include for this unless you want to validate something or fetching records from another table than glide list table.

Just add the condition to the reference qualifier field:

javascript:'active=false'; // OR just active=false

 

Thanks

Anand

View solution in original post

14 REPLIES 14

Hi @Erica2 ,

Make a new script include without client callable.

Sudeep5
Tera Contributor

You don't need a script include for this. You can have filter applied directly.

use the following in Reference qualifier field.

javascript: "u_active=false"

 

Please check the exact column name of active field, incase it is not 'u_active' use teh exact column name.

Ankur Bawiskar
Tera Patron
Tera Patron

@Erica2 

why you require script include?

what do you mean by few records? how many 5 or 10 or 100?

you can directly form the encoded query and copy paste there

javascript: 'u_active=false';

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

Hi @Ankur Bawiskar ,

 

I'm still learning, and I didn't initially know how to retrieve the data correctly.

 

I had tried using the expression javascript: u_active=false, but it didn’t work.

 

As I understand it now, static queries don’t require the javascript: prefix.

 

Using just u_active=false works correctly.

 

What I meant by "a few records should be returned" is that I purposely inactivated a few records to test whether the changes were working as expected.

@Erica2 

I believe I shared the solution as well with direct encoded query of u_active=false

I could see other response marked as correct.

As per new community feature you can mark multiple responses as correct.

If my response helped please mark it correct as well so that it benefits future readers.

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