IT CanvassTalk to an advisor
Development ยท LessonBy , ServiceNow Architect ยท Updated

Notifications & email scripts

Send the right message to the right people, with dynamic content via mail scripts.

Quick answer

Notifications send email (and push/SMS) when something happens, a P1 incident, an approval request, an SLA breach. They are configured records: a when to send trigger, a who to send to audience, and a what to say body. Email scripts inject dynamic, computed content into that body.

Key takeaways
  • How a notification fires
  • A mail script
  • Best practices
  • Try it Yourself

Notifications send email (and push/SMS) when something happens, a P1 incident, an approval request, an SLA breach. They are configured records: a when to send trigger, a who to send to audience, and a what to say body. Email scripts inject dynamic, computed content into that body.

How a notification fires

  • Trigger, record inserted/updated matching a condition, or an event raised by code.
  • Recipients, users, groups, fields on the record (e.g. Assigned to), or dynamic lists.
  • Content, a template with field variables like ${number} and mail scripts for logic.

A mail script

// In the notification body: ${mail_script:sla_line} (function runMailScript(current, template, email, email_action, event) { if (current.priority == '1') { template.print('\u26a0 This is a P1 and needs immediate attention.'); } })(current, template, email, email_action, event);
Events decouple the trigger. For anything beyond a simple field condition, raise an event (gs.eventQueue()) from a business rule and have the notification listen for it. This keeps notification logic out of your business rules and makes the trigger reusable.

Best practices

  • Use notification email scripts, not inline logic, for anything conditional.
  • Respect subscription preferences and avoid notification storms.
  • Test with the preview and check the email logs.
Practise this on your own free instance.
Set up your free instance →

Practice challenge

3 questions
Q1An email script is used to...

Inject dynamic content into the message

Email/mail scripts compute dynamic notification content.

Q2To decouple a complex trigger, you should...

Raise an event with gs.eventQueue()

Events let notifications listen without coupling to business rules.

Q3A field variable in a template looks like...

${number}

Notifications use ${field} substitution.

Frequently asked questions

What does the term Notifications & email scripts refer to in ServiceNow?
Notifications send email (and push/SMS) when something happens, a P1 incident, an approval request, an SLA breach. They are configured records: a when to send trigger, a who to send to audience, and a what to say body. Email scripts inject dynamic, computed content into that body.
What is another point to note about Notifications & email scripts?
Trigger, record inserted/updated matching a condition, or an event raised by code. Recipients, users, groups, fields on the record (e.g. Assigned to), or dynamic lists.
What else is worth knowing about Notifications & email scripts?
Use notification email scripts, not inline logic, for anything conditional. Respect subscription preferences and avoid notification storms. Test with the preview and check the email logs.

Want this taught live, with job support?

ServiceNow Training is delivered live by working practitioners, with certification prep and placement support.

See ServiceNow Training โ†’