Event param1 recipientnot pass in my notification ??

wakespirit
Kilo Guru

Dear all,

I have a business rule which is define on INSERT on table Group member in order to send a email notification to the added user top the group.

The content of by business rule script is simlple as below :

function myBusinessRuleFunction() {
   try {
	   
	   var user=current.user.first_name;
	   gs.warn('ADDED USER :' + user);
	   var rec=current.user;
	   gs.warn('ADDED USER :' + rec);
	   gs.eventQueue('added.member',current,rec);
      
   } catch(exception) {
      // Specify the name of the Business Rule in the log message
      gs.warn('Error in the Business Rule <User_Member_Added>: ' + exception, '*** Script');
   }
}

I have verified from the log that current.user is valid and I get the sys_id value.

Then when I pass the variable "rec" to my event parameter as param 1, when I check in my notification that event param 1 is a recipient, when my event is trigged no email is send.

If I force the recipient to my self as a who will recieve, then email is sent correctly.

Any idea why the param1 cannot be seen as recipient for my email, did I miss something ?

thanks for help

regards

3 REPLIES 3

Paul Curwen
Giga Sage

May seem obvious but check that you have ticked Event parm 1 contains recipient in the notification. Parm1 should specify the sys_id of the user you want to send the email to - not the actual email address, so you are sending the correct value there.

 

If you are testing as yourself and sending to yourself and your actions are generating the event, tick the 

 
that ones easy to miss 🙂


Also check the event log and ensure that event is both firing and processing. 

***If Correct/Helpful please take time mark as Correct/Helpful. It is much appreciated.***

Regards

Paul

Service_RNow
Mega Sage

Hi,

You can pass multiple values separated by a comma.   The email notifications just need a comma separated list of user sys_id's and you don't need to pass the name unless you want them to show up in the email to line.   If you don't pass it, then just the email address will be present.   Here is some example code to get a list of users and create an array that you can then pass to an event:

var userList = [];

var userRec = new GlideRecord("sys_user");

userRec.addEncodedQuery(YOUR-ENCODED-QUERY);

userRec.query();

while (userRec.next()) {

      if (userList.toString().indexOf(userRec.sys_id) == -1) {

               userList.push(userRec.sys_id + "");
       }
}
 

gs.eventQueue("EVENT-NAME", current, userList.toString());

 In my example code, emails will be in parm1

 

Thanks

my issue was coming from the fact that the user I was adding did not have allow notification set to true