how to send an email when manager is from those groups only

raj765_32
Tera Contributor

hi can anyone help me with the case that there is an order guide and from the user table there is a field field called status change which is a  drop down, when ever status change is initiated i want to trigger an email to the hiring managers whoare only from a two groups .

i.e process specilaist group and service now dev group

managers from these two groups who ever selected in user record's manager needs to get email...

 

in notification in when to send i have checked inserted and updated, and status change changes to initiate  but how can i select the condition that send email when managers are only form the above groups?

10 REPLIES 10

Siva Jyothi M
Mega Sage

Hi @raj765_32,

 

I believe you can achieve this through Business rule where you can check if the user is part of the groups mentioned and call the event from BR and with the event the notification will be triggered.

 

Please mark this answer as correct and helpful if it solves your issue.

Regards,

Siva Jyothi M.

can you please help me with the code for it?

Hi @raj765_32.,

 

Create a insert or update BR on the User table with the below code. Add the when to run condition. Replace the backed values according to the requirement.

var gr = new GlideRecord('sys_user_grmember'); // Table stores the mapping of user and group.
gr.addQuery('user', current.sys_id); 
gr.addQuery('group', '<sys_id_group>');//you can add encoded query as well here
gr.query();
if(gr.next()){
  gs.info("User is Member of Group!");
}
else{
  gs.info("User is Not a Member of Group!");
}

Please mark this answer as correct and helpful if it solves your issue.

Regards,

Siva Jyothi M.

hi siva jyothi, where am i adding gs.event queue over here?

i created an event with name status.initiate