Reference Qualifier not working proeprly

PK16
Tera Expert

Hi,

 

On incident form cmdb_ci field and assignment_group fields are present.

I want cmdb_ci records which are having support group same as assignment_group.

How to achieve this ?

PK16_0-1692714137971.png

 

My existing code not working :

I'm getting correct 12 records sys_id in in logs but not gettings records in the cmdb_ci

Reference Qualifier :

javascript: new restrictCallers().getCMDBdata(current.assignment_group);

 

Script Include :

var restrictCallers = Class.create();
restrictCallers.prototype = {
    initialize: function() {},

 
    getCMDBdata: function(groupid) {
        var cmdbArr = [];
        var GlideGroup = new GlideRecord('cmdb_ci');
        GlideGroup.addQuery('support_group', groupid);
        GlideGroup.query();
        gs.info("Group ID: " + groupid);
        gs.info("Number of CMDB records found: " + GlideGroup.getRowCount());
        while (GlideGroup.next()) {
            cmdbArr.push(GlideGroup.sys_id.toString());
        }
        //gs.info("CMDB array:"+cmdbArr.join(','));

         return "sys_idIN"+cmdbArr.join(',');
    },



    type: 'restrictCallers'
};

 

6 REPLIES 6

Eswar Chappa
Mega Sage
Mega Sage

Hi @PK16 your use case is like "Need to show the CI's based on the match of Support group of CI with assignment group choosen right?

Correct. Do you know what I'm doing wrong here ?

umaaggarwal
Giga Guru
Giga Guru

Please try using below 

 

 

return "sys_idIN"+JSON.stringify(cmdbArr);

Hi @umaaggarwal ,

I tried your suggestion, but still it gives me 0 records and that array has total 12 sysid's in log.