How to pass various sys ids in the parm 1 in an event

AB6
Tera Contributor

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

 

1 ACCEPTED SOLUTION

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);

View solution in original post

16 REPLIES 16

AB6
Tera Contributor

In the background script works 😄
but in the business rule is not working 😞

I checked with logs the business rule and is not taking the CI 

find_real_file.png

Can you paste the BG script here ?

AB6
Tera Contributor

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);

I meat the script which you ran in background.

AB6
Tera Contributor
var test = new GlideRecord('cmdb_ci');
test.addQuery('sys_id' , 'de741529db369f80573c7badae9619db');
test.query();

if(test.next()){


	var assiGroups = new testUtils().getAssiGroups(test);
gs.log('assiGroups'+ assiGroups, 'assiGroups');
	gs.eventQueue('groups.inserted', current, assiGroups.toString());

gs.print(assiGroups );
	

 

find_real_file.png