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

Shivalika
Mega Sage

Hello @Siva82 

 

The methid that you are calling via script include in your reference qualifier is "grtCIFilterForeRetire" and the function that you have defined within script include is "getCiFilterForQualifier" - please correct the function name. 

 

Additionally, you have added if condition on ci_class, but you haven't referenced from where, and it should be u_ci_class. 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway,

 

Regards,

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY

Rohit  Singh
Mega Sage

Hi @Siddhesh Gawade ,

 

  1. One issue i found that you are using one getCIFilterForRetire() this is reference qualifier and  getCIFilterForQualifer function in Script Include.
  2. I don't see ci_class being defined any where in the script include function. What value it is storing?
  3.  You are using  var u_id = gs.getUserID();   ->Is there any variable in your catalog which is pointing to sys_user table and you want that user to be in your filter condition dynamically?

If my response helped, please mark it helpful and accept the solution so that it benefits future readers.

 

Regards,
Rohit

Ashish Parab
Mega Sage

Hello @Siva82 ,

 

Please check your script include name as well as the function name you used in the reference qualifier.

 

Reference qualifierjavascript: new FMC_CI_check().getCIFilterForQualifer();

 

Please mark this as "correct" and "helpful" if you feel this answer helped you in anyway.

 

Thanks and Regards,

Ashish