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

Hi @PK16 I had checked it the code is working fine in the Background script  as below:

EswarChappa_0-1692716592523.png

 

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());
        }
		 return "sys_idIN"+JSON.stringify(cmdbArr);
    },
    type: 'restrictCallers'
};

 

EswarChappa_1-1692716680575.png

 

PK16
Tera Expert

The issue is resloved, actually cmdb_ci field is dependent on the company field and because of that it is not showing records, once I removed that then it started showing me the records.

Thanks everyone