Workflow - send notification to an email address in a variable

Christoffer Lin
Tera Contributor

Hi,

 

I have a record producer (which triggers my workflow) with a "single line text-variable" called emailaddress. 

 

In my workflow, I want to send a notification to the value entered in the emailaddress-variable.

 

Is this possible through the Notification-action in my workflow or do I have to create an event which triggers an email notification? If I need to trigger an email notification in the sysevent_email_action table - do I have to use an email script which fetches my variable-value?

 

Thanks in advance!

 

 

 

 

4 REPLIES 4

Community Alums
Not applicable

Hi, Yes you can do this through the notification activity in a workflow.

Musab Rasheed
Tera Sage
Tera Sage

Hello,

Looks like you can add directly in Advance section of Notification activity with simple code like below. try once.

MusabRasheed_0-1669213431915.png

Please hit like and mark my response as correct if that helps
Regards,
Musab

AnubhavRitolia
Mega Sage
Mega Sage

Hi @Christoffer Lin 

 

You can also do this by using notification activity in your workflow.
In your notification activity, just check the Advanced checkbox and then write this script in it.



var emailID=current.variables.emailaddress ;
answer = [emailID];

 

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023

Mohith Devatte
Tera Sage
Tera Sage

Hello @Christoffer Lin ,

 

Yes you can do it in workflow activity.But you might have to write some script to push the notification like below in the advanced section 

var gr = new GlideRecord('sys_user');
gr.addQuery('email',current.variables.your_variable_backend_name);
gr.query();
if(gr.next())
{

answer = gr.sys_id.toString();
}

 

Screenshot 2022-11-23 at 20.05.02.png

 

Hope this helps 

If this helped you mark my answer correct

Thanks