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 07:33 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 07:35 AM
Correct. Do you know what I'm doing wrong here ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 07:38 AM
Please try using below
return "sys_idIN"+JSON.stringify(cmdbArr);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 07:42 AM
Hi @umaaggarwal ,
I tried your suggestion, but still it gives me 0 records and that array has total 12 sysid's in log.