How to send group name as parameter to notification

wakespirit
Kilo Guru

Dear all,

I have define a notification which is trigger by an event.

I have then created a notification which will be fired by the event but I need to set the Who Will receive Group dynamically as it will depend on the context of the event

Q 1 : guess the idea is to pass the group sys_id as parameter to the event correct ?
Q2 : how can I set the group of the Who will receive of my notification based on the event parameter ? 

Thanks for help

regards

1 ACCEPTED SOLUTION

Good to know, can you mark my answer correct to close the thread down?

View solution in original post

4 REPLIES 4

Dubz
Mega Sage

I believe the 'event parm1 contains recipient' field only works if you're passing through a user sys_id or an email address, worth testing with a group sys_id though.

Assuming the group sys_id doesn't work, the best way around it is to add the members of the group to an array and then pass that array of users through as event parm1.

var grp = current.getValue('assignment_group'); //or wherever you're getting the group from
var arr = [];

var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group', grp);
gr.query();
while(gr.next()){
arr.push(gr.getValue('user');
}
gs.eventQueue('your.event.name', current, arr);

thanks I will give a try and let you know

Passing group id as part of parmater 1 of event works fine.

By the way do you have any idea of this related post that I sumbit ?

 https://community.servicenow.com/community?id=community_question&sys_id=ae251727db83a740d6a102d5ca9...

 

Good to know, can you mark my answer correct to close the thread down?