how to use event name in email script

Saurav Bhardwa2
Tera Contributor

Hello,

I have a requirement where we are triggering a notification sent to 'abc' and 'xyz. These two emails are currently added directly in the notification itself. However, the new requirement is to configure the email sender list differently. Specifically, "abc:" should be placed in the "TO" field, and "xyz" should be placed in the "BCC" field of the email.

We have a UI action that triggers the event for this notification, and below is the script for that UI action:

if (current.severity == 1) // Alpha
{gs.eventQueue('incident.notification.alpha', current, gs.getUserID(), gs.getUserName());
// gs.addInfoMessage('Your email has been sent!');
}
Is it possible to dynamically set the "TO" and "BCC" sender list in the email script based on the event name provided in the UI action?
2 REPLIES 2

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Saurav Bhardwa2 ,

 

Yes you can set the recipients name dynamically.

You need to create a email script & call the same in the notification mail body like below:

${mail_script:set_reciepient} // instead of set_recipient provide the name of ur mail script

 

Then in ur email script u can access the event parameters like ${event.parm1} & $ {event.parm2}

 

Parm1 & Parm2 will contain recipients email I'd/sys I'd which needs to be added in Bcc(this will be taken care in email script) n To( this will be taken care in the notification whom to send section where u can check on the send to event parameter 1 checkbox)

 

Please mark my answer helpful & accepted if it helps you resolve your query.

 

Thanks,

Danish

 

 

NaveenGN
Tera Expert

Hello @Saurav Bhardwa2,

In you event try to send your abc and xyz user as array in the event if they are dynamic then glide record these users email and name from the sys_user table.

Or if they are static directly use 

email.addAddress('to','abc@example'.com,'name of abc') and for bcc change to ==> bcc and give xyz user d=mail and name

 

email.setSubject('Item requested is '+current.number);
	email.addAddress("cc", current.requested_for.email, current.requested_for);
	email.setBody('You have requested item is successfully ordered and your item number is '+current.number);
//just for your reference

 

Please mark as correct if it is a solution It would help for other community members

Best Regards,

Naveen G N