Send two separate emails from one notification?

josephtucker
Giga Contributor

I am looking to create a single email notification that will utilize mail scripting to send out two emails (containing different bodies) depending on who is in the recipient list.

For example:

I have an email notification on the incident table that lists the Watch List and Caller as people who will receive the notification.

I want to be able to have a script look at each user within this list (be it 1 person or 50 people) and send out emails based on their role level.

If an incident is created and the Caller is on role level 1 and two people on the watch list are on role level 1, I want an email to be sent to them.

However, if there are 2 more people on the same watch list that are of role level 2, I want a separate email to be sent to this group.

Level 1 emails would see short description and long description in the email (for example)

Level 2 emails would see the same as Level 1, but also include Priority (for example).

I'm curious if this is possible to do within one single Email notification while using mail scripting.

I want to avoid using two email notifications per role level in this case.

1 ACCEPTED SOLUTION

tony_fugere
Mega Guru

Unfortunately, there is not a "ServiceNow Best Practices" way to accomplish this without creating two separate email notifications. I do not believe you will accomplish it with an email script, because the email script applies to the email sent regardless of recipients. You do not get the option to say "only include this content if the recipient is Level 2". Now, I say best practices because you could potentially hack some Business Rules on the sys_email table to inject content into the body of the email record that belongs to Level 2 or split out the sys_email records with injected content in the one that goes to Level 2, but that is NOT ideal for a ServiceNow Administrator to manage and I do NOT recommend it.



Don't forget about Email Templates though as they could be of some assistance in this case (at least in terms of managing most of the same content in two places).


View solution in original post

2 REPLIES 2

tony_fugere
Mega Guru

Unfortunately, there is not a "ServiceNow Best Practices" way to accomplish this without creating two separate email notifications. I do not believe you will accomplish it with an email script, because the email script applies to the email sent regardless of recipients. You do not get the option to say "only include this content if the recipient is Level 2". Now, I say best practices because you could potentially hack some Business Rules on the sys_email table to inject content into the body of the email record that belongs to Level 2 or split out the sys_email records with injected content in the one that goes to Level 2, but that is NOT ideal for a ServiceNow Administrator to manage and I do NOT recommend it.



Don't forget about Email Templates though as they could be of some assistance in this case (at least in terms of managing most of the same content in two places).


Yeeeaaaaah,


I figured I could potentially hack it, but that's not exactly ideal, from a performance perspective, or from a best practices perspective as you've described.


I'll end up creating the two separate notifications then. It's thankfully not going to be an issue with my clients.



Thanks for the help!



Cheers!