Why gs.eventQueue not working?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2022 06:38 AM
Hi community,
My requirement is to trigger the notifications to customer admins when any Blocked by record is created for their related accounts.
I'm triggering event through gs.eventQueue() but it's not working.Although logs are priniting the values fine.
Below is the BR:-
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var contacts=[];
gs.info('account: ' + current.blocked_task.account.getDisplayValue());
var gr = new GlideRecord('customer_contact');
gr.addQuery('account', current.blocked_task.account);
gr.query();
while (gr.next()) {
gs.info('sys_id: '+gr.sys_id);
var gr1 = new GlideRecord('sys_user_has_role');
gr1.addQuery('user', gr.sys_id);
gr1.addQuery('role','9b94fc24d7700200e5982cf65e610358');
gr1.query();
gs.info('no: '+gr1.getRowCount());
while (gr1.next()) {
gs.info('cust admin role: '+gr1.user.getDisplayValue());
contacts.push(gr1.user);
}
}
gs.info('admins: '+contacts);
for(i=0;i<contacts.length;i++){
gs.eventQueue('blocked_by_event_registry',current,contacts[i],gs.getUserID()) ;
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2022 06:49 AM
Hi
You have not defined i hence seeing issue just define var i in for loop like below.
for(var i=0;i<contacts.length;i++)
if still doesn't work then replace code like this
Replace
for(var i=0;i<contacts.length;i++){
gs.eventQueue('blocked_by_event_registry',current,contacts[i],gs.getUserID()) ;
}
with
for(var i=0;i<contacts.length;i++){
emailTo = contacts[i];
gs.eventQueue('blocked_by_event_registry',current,emailTo ,gs.getUserDisplayName()) ;
}
Mark my answer as correct or hit like based on impact.
Regards
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2022 07:07 AM
Hi Musab,
Thanks for the response.
It's working now. The event name was incorrectIt should be sn_customerservice.blocked_by_event_regi.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2022 07:15 AM
Ok cool , you didn't declared i as well right.? anyways mark answer as correct and close the thread.
Regards,
Musab