Script include in List collector's reference qualifier

ILYA STEIN
Tera Guru

In a catalog item, I have a list collector that I need to dynamically filter based on the selection in another variable. I created a script include and invoke its method in the list collector's reference qualifier, but the list collector doesn't behave as expected. To simplify things, I changed the script include to return a simple string. When I define the reference qualifier as follows, everything works as expected (the list collector's table is cmdb_ci_server):

javascript: "operational_statusNOT IN3,12,6^u_bigfix_computer_idISNOTEMPTY^nameISNOTEMPTY"
However, when I invoke the script include's method, the list collector doesn't filter. Here is the code:
Script include:
var RE_Include = Class.create();
RE_Include.prototype = {
    initialize: function() {
    },
serverSelectionFilter: function() {
    return "operational_statusNOT IN3,12,6^u_bigfix_computer_idISNOTEMPTY^nameISNOTEMPTY";
},
    type: 'RE_Include'
};
Reference qualifier:
javascript: new RE_Include().serverSelectionFilter();

What am I doing wrong?
1 ACCEPTED SOLUTION

YaswanthKurre
Giga Guru

Hi @ILYA STEIN ,

 

When you are calling a script include from variables, So this executes client-side, but Script Includes are server-side code. Unless the Script Include is marked as client-callable, it won't work from the client side.

 

Please update your server side script to be client callable, code:

var RE_Include = Class.create();
RE_Include.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    serverSelectionFilter: function() {
        return "operational_statusNOT IN3,12,6^u_bigfix_computer_idISNOTEMPTY^nameISNOTEMPTY";
    }
});

 

Please mark this as helpful and correct if this resolves your issue.

 

Thanks,

yaswanth

View solution in original post

2 REPLIES 2

YaswanthKurre
Giga Guru

Hi @ILYA STEIN ,

 

When you are calling a script include from variables, So this executes client-side, but Script Includes are server-side code. Unless the Script Include is marked as client-callable, it won't work from the client side.

 

Please update your server side script to be client callable, code:

var RE_Include = Class.create();
RE_Include.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    serverSelectionFilter: function() {
        return "operational_statusNOT IN3,12,6^u_bigfix_computer_idISNOTEMPTY^nameISNOTEMPTY";
    }
});

 

Please mark this as helpful and correct if this resolves your issue.

 

Thanks,

yaswanth

palanikumar
Mega Sage

Hi,

: is not required in Reference qualifier. Use the below:

javascript:new RE_Include().serverSelectionFilter();

Thank you,
Palani