How to set the 'from' field in email notification

Averell
ServiceNow Employee
ServiceNow Employee

I've created a new table. When the state field changes to 'sent' an email should be sent. Everything works fine, but not the 'from'-email address.

I want to send out the email from the user who has updated the record. The reply address should be always the same.

In the 'What will it contain'   section of the definition in both the subject field and the message field the ${xyz} notation works, but not in the 'from' field. It looks the 'from' field is just a string field. No mechanism works on it to pass the required address ... Any idea?

1 ACCEPTED SOLUTION

Leave the from and reply to fields blank


Create a new 'Notification email script' say email_from having following code




email.setFrom(current.user.email);


email.setReplyTo(current.user.email);                                     //please review for backend name of updated by 'user' field




Now call this notification script from the notification's Message HTML field as follow


${mail_script:email_from}


View solution in original post

8 REPLIES 8

Leave the from and reply to fields blank


Create a new 'Notification email script' say email_from having following code




email.setFrom(current.user.email);


email.setReplyTo(current.user.email);                                     //please review for backend name of updated by 'user' field




Now call this notification script from the notification's Message HTML field as follow


${mail_script:email_from}


Averell
ServiceNow Employee
ServiceNow Employee

Thank you Gurpreet Singh ! Thats the solution!!


Hello Gurpreet,

 

I see update by field is a string field , how should i dot walk to get the email.

Please let me know .

 

Thanks,

Amar

There are multiple ways. GlideRecord the user table and fetch his email address.

1. You could pass the email as event parameter from Bossiness rule

2. If notification is not event based than you possibly need to write GlideRecord code in email notification script

https://developer.servicenow.com/dev.do#!/learn/learning-plans/orlando/new_to_servicenow/app_store_learnv2_automatingapps_orlando_notification_email_scripts