Function: EmailNotification(config)
Creates an email notification configuration for ServiceNow. Email notifications are automated messages sent to users when specific conditions are met, such as record updates, insertions, or system events.
This API allows you to define notifications with trigger conditions, recipient targeting, email content, and digest options. Notifications can be triggered by database operations (insert/update), system events, or manual execution.
Parameters
config
EmailNotification<keyof Tables>
Email notification configuration object
Properties:
-
table (required):
keyof TablesThe table that this notification applies to (required) -
active (optional, default: true):
booleanWhether the notification is active and will be sent -
category (optional, default: 'c97d83137f4432005f58108c3ffa917a' (Default email category)):
string | Record<'sys_notification_category'>Category for organizing and managing notifications -
description (optional):
stringDescription of the email notification -
digest (optional):
DigestDigest configuration for batching multiple notifications -
emailContent (optional):
EmailContentEmail content and formatting options -
enableDynamicTranslation (optional, default: false):
booleanWhether to enable dynamic translation of notification content -
mandatory (optional, default: false):
booleanWhether the notification is mandatory and cannot be unsubscribed from -
name (optional):
stringName of the email notification -
notificationType (optional, default: 'email'):
'email' | 'vcalendar'Type of notification: email or calendar invite (vcalendar) -
recipientDetails (optional):
RecipientDetailsConfiguration for who receives the notification -
triggerConditions (optional):
TriggerConditions<keyof Tables>Conditions that determine when the notification is triggered
Examples
Basic Email Notification Example
Create an email notification that fires when an incident is inserted or updated
/**
* @title Basic Email Notification Example
* @description Create an email notification that fires when an incident is inserted or updated
*/
import { EmailNotification } from '@servicenow/sdk/core'
export const IncidentCreatedNotification = EmailNotification({
$id: Now.ID['incident-created-notification'],
table: 'incident',
name: 'Incident Created Notification',
description: 'Notify assigned user when an incident is created or updated',
active: true,
triggerConditions: {
onRecordInsert: true,
onRecordUpdate: true,
},
recipientDetails: {
recipientFields: ['assigned_to'],
},
emailContent: {
subject: 'Incident ${number}: ${short_description}',
messageHtml:
'<p>An incident has been created or updated.</p><p>Number: ${number}</p><p>Priority: ${priority}</p>',
},
})