How to send email notification to different recepient based on condition which triggers by WF event?

ads
Tera Expert
Hi All, I created a notification which will trigger on event is fired, Event is fired through the "create event" workflow activity. I need to send the notification to 'requested for' user if a variable of a catalog item value is 'Yes', If the variable value is 'No', It will send the email notification the 'requested for' user and an email ID - xyz@gmail.com. Can anyone please help me out how to do it ?
3 REPLIES 3

Mohith Devatte
Tera Sage
Tera Sage

Hello @ads ,

You can use Param1 scripting field to send recipients as paramters and then check "event parm1 contains recipient" check box in who will receive tab in notification 

(function() {
	if(current.variables.your_variable_name=="yes")
		{
			return current.variables.requested_for_variable_name; // replace requested for variable name
		}
	else{
		var arr =[];
		arr.push(current.variables.requested_for_variable_name); // replace requested for variable name
		arr.push("abc@email.com");
		return arr.toString();
	}
	
}());

 

Screenshot 2023-08-24 at 19.43.02.png

 

Hope this helps 

Mark my answer correct if this helps you 

Thanks

Hi @Mohith Devatte ,

The above script is not working, Can you please let me know one thing if I want to send the notification to the eamil id only, how to write that script.

hello @ads ,

if that user having the  email ID is present in the system try glide recording to user table and get the sys_id of the user and then return  it 

var gr  = new GlideRecord('sys_user');

gr.addQuery('email','your_email_id');

gr.query();

if(gr.next())

{

return gr.sys_id.toString();

}

Mark the answer correct if this helps you 

Thanks