Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

apply reference qualifier for Cmdb_Ci table in variable

Siva82
Tera Expert

 

Hi Team,

 

I have applied a reference qualifier for a variable in a catalog item and tried using a script include for it. I am retrieving CI classes from a custom table and applying them to the CMDB CI table to filter CIs. However, it is not working. Can you help with this?

Reference qualifier: javascript: new FNC_Util( ).getCIFilterForRetire();

 

Script inculide 

var FMC_CI_check = Class.create();
FMC_CI_check.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    getCIFilterForQualifer: function() {
        var filter = '';
        var filter_retire_ci = [];
        var ci_list = new GlideRecord('u_retire_templates');
        ci_list.addEncodedQuery('u_create_task=true^u_active=true^u_ci_classISNOTEMPTY');
        ci_list.query();
        while (ci_list.next()) {

            //  var filter_Ci2 =
            filter_retire_ci.push(ci_list.u_ci_class.toString());



        }
        var u_id = gs.getUserID();

        if (ci_class != '') {

            filter = "sys_class_nameIN" + filter_retire_ci + "^assigned_to=" + u_id + "^install_status=1"; //installed

            return filter;

        } else {
            return '';
        }
    }

    type: 'FMC_CI_check'
});

Thank you in advance 
Siva
1 ACCEPTED SOLUTION

Can you try return filter.toString(); while returning the filter. 

View solution in original post

7 REPLIES 7

Siddhesh Gawade
Mega Sage
Mega Sage

Hello @Siva82 ,

 

In the if condition you are checking "ci_class" which is not defined. So correct that first. 

And while returning the filter use return filter.toString();

 

Kindly mark the answer ✔️ Correct or Helpful ✔️ If it addresses your concern.


Regards,

Siddhesh

 

@Siddhesh Gawade 

Thank you for quick response.
I have done the changes . Below scrpit. But not works

var FMC_CI_check = Class.create();
FMC_CI_check.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    getCIFilterForQualifer: function() {
        var filter = '';
        var filter_retire_ci = [];
        var ci_list = new GlideRecord('u_retire_templates');
        ci_list.addEncodedQuery('u_create_task=true^u_active=true^u_ci_classISNOTEMPTY');
        ci_list.query();
        while (ci_list.next()) {

            //  var filter_Ci2 =
            filter_retire_ci.push(ci_list.u_ci_class.toString());



        }
        var u_id = gs.getUserID();

        if (filter_retire_ci != '') {

            filter = "sys_class_nameIN" + filter_retire_ci + "^assigned_to=" + u_id + "^install_status=1"; //installed

            return filter;

        } else {
            return '';
        }
    }

    type: 'FMC_CI_check'
});

Can you try return filter.toString(); while returning the filter. 

@Siddhesh Gawade Thank you for your help its works now