- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2018 01:06 AM
Hi community!
I want to pass various sys ids in the parm 1 in an event.
I have a function in a script include that has an array
var array= [];
array.push(groups.sys_id.toString());
return array;
Actually the function is working perfectly returning all the sys_id ´s groups
The problem is when I try to use this return to a event queue, the event parm 1 is not taking anything.
gs.eventQueue('groups.inserted', current, array);
Any idea how to take the array into the eventQueue?
Regards
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2018 02:26 AM
Thanks,
(function executeRule(current, previous /*null when async*/) {
var ci = current.cmdb_ci;
var gr = new GlideRecord('cmdb_ci');
if(gr.get(ci))
var assiGroups = new testUtils().getAssiGroups(gr); // passing the object instead of sys_id
gs.eventQueue('groups.inserted', current, assiGroups.toString());
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2018 01:10 AM
Hi,
Can you provide your whole code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2018 01:20 AM
Hi @Shweta
Here the code in the after business rule:
(function executeRule(current, previous /*null when async*/) {
var ci = current.cmdb_ci;
var assiGroups = new testUtils().getAssiGroups(ci);
gs.eventQueue('groups.inserted', current, assiGroups.toString());
})(current, previous);
Here the function in the testUtils script include:
getAssiGroups: function(ci){
var aGroup = [];
var CIUtil = new CIUtils();
var ciT = ci.getUniqueValue();
var serviceIds = CIUtil.servicesAffectedByCI(ciT);
for (var i=0; i < serviceIds.length; i++) {
var service = new GlideRecord("cmdb_ci_service");
service.get(serviceIds[i]);
aGroup.push(service.assignment_group);
}
return aGroup.toString();
},

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2018 01:27 AM
Hi,
the code is correct, it is passing multiple values in third parameter(event.parm1) already. Please check on event log, if you are getting an array as first parameter.
gs.eventQueue('groups.inserted', current, assiGroups); // do not stringify the array
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2018 01:33 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2018 01:38 AM
Hi,
Can you check logs if you are getting any return values at all.
(function executeRule(current, previous /*null when async*/) {
var ci = current.cmdb_ci;
var assiGroups = new testUtils().getAssiGroups(ci);
gs.log('assiGroups'+assiGroups, 'assiGroups');
gs.eventQueue('groups.inserted', current, assiGroups.toString());
})(current, previous);