Reference Qualifier not working proeprly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 07:24 AM
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 ?
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'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 08:04 AM - edited 08-22-2023 08:05 AM
Hi @PK16 I had checked it the code is working fine in the Background script as below:
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'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 08:16 AM
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