- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 06:30 PM
Hello,
My org uses our own SMTP server which uses the Service Desk email address as the "From" field on the sys_email_account record. We have recently implemented HRSD, and we want to ensure that notifications in the HR category are sent using the HR mailbox instead of the Service Desk mailbox. I've gone into a test notification and set the 'From' and 'Reply To' values as the HR email address, however when the notification is triggered, it is still being sent from the Service Desk mailbox.
What settings should I be looking at to correct this behaviour?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2023 03:08 AM
Hi Atulya,
I appreciate your response. Thankfully I've found the cause of the issue. There was a business rule that was triggered when the sys_email record state changed to 'ready', and it would set the values of the From and Reply to fields. I'm not sure why this was initially implemented, but after disabling this business rule I have been able to change the values of the From field using either the fields on the notification, or by attaching a mail_script that calls the email.setFrom() function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2023 07:48 PM
The easiest way for you to achieve this without code:
1. Go to your sysevent_email_action table
2. Create a copy of the notification that is being used where you want to set the From and Reply To
3. In the copy of the notification, set the From and Reply To fields to the address of your Critical Incident mailbox. (If you cannot see the From and Reply To fields, you may have to edit the layout of the form)
4. In the copy of the notification where you have set the 'Reply To' and 'From' fields, go into the 'When to Send' section of the notification and add a condition to only send when the incident is in the Major Incident category.
5 In the original notification (not the copy you created), go into the 'When to send' section, and add a condition to only send only when the incident is NOT in the Major Incident category.
I used a more code-based solution that achieved the same goal:
1. Create an email notification script that calls 'email.setFrom(<email>)' and 'email.setReplyTo(<email>)', where <email> is the value of the email address to want to send from. Below is the script that I am using, because the email I want to send from is the same email listed as the sn_hr_core.hr_email system property.
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var props = gs.getProperty('sn_hr_core.hr_email');
email.setFrom(props);
email.setReplyTo(props);
})(current, template, email, email_action, event);
2. Have attach this script to any of the records that form the outbound email by putting '${mail_script:<name of script>}', where <name of script> is the name of your notification script. In my case, I placed this script in the body of an sys_email_layout record because all of the HR notifications in my instance use this layout. You could attach it directly to a notification record if you wanted to.
The issue I initially had was that when I set the 'From' and 'Reply To' fields on my notifications, they still weren't applying. This was because there was a business rule that was also being run that changed those fields back. After deactivating that business rule, the 'Reply To' and 'From' fields were behaving as expected.