Notification recipients and content
Script patterns for notification recipients, subject and body substitutions, context scripts, attachments and scripted sends.
This page collects the script patterns an outbound notification uses: who receives it, what the subject and body say, and what a script can pass in. It is for administrators and developers writing the script fields described in Outbound notifications.
Script fields and where they live
| Field | Enhanced Notifications (v2) | Classic Email Notifications (v1) | Sets answer to |
|---|---|---|---|
| Condition | Notification | Notification | True or false |
| Recipients | Notification | Notification | An array of recipients |
| Context script | Notification and provider configuration | Notification | An object of named values |
| Messaging account | Provider configuration | Notification | A messaging account ID |
| From | Provider configuration | Notification | A sender address |
| Subject, body | Messaging template (Subject, HTML Template) | Notification (Subject, Body) | Not a script. Text with substitutions. |
Every script can read current, the record the notification runs for. The OutboundNotificationSupport script library has fromAddress(record) and messagingAccount(record) functions you can fill in to set both values for every notification in one place.
Recipients
Recipients must end by assigning an array to answer. An entry can be an email address, a string field holding an address, a user reference or a multiple reference to users. Servicely uses each user’s email address and sends each address one message.
| Entry | Example | Resolves to |
|---|---|---|
| Fixed address | An address in quotes | That address |
| String field | current.Email() |
The address in the field |
| User reference | current.Requestor() |
The user’s email address |
| Multiple reference | current.relation("Follower") |
Each user’s email address |
| CC recipient | cc(current.Requestor()) |
A CC address. Ignored when Send individually is on. |
| BCC recipient | bcc(current.relation("SecretFollower")) |
A BCC address. Ignored when Send individually is on. |
Combine sources
let toList = [
current.relation("Follower"),
current.RequestedFor(),
current.Email()
];
if (current.Assignee()) {
toList.push(current.Assignee());
}
answer = toList;
Add the members of follower groups
FollowerGroups here is a multiple reference to groups. The script adds every active member of each group.
let toList = [];
let groupIds = current.getRelation("FollowerGroups").map(group => group.ID());
for (let i = 0; i < groupIds.length; i++) {
let userRec = Table("User")
.SUBQUERY("Group", EQUAL("Id", groupIds[i]))
.EQUAL("Active", true)
.query();
while (userRec.next()) {
toList.push(userRec.Email());
}
}
answer = toList;
Subject and body
The subject and body mix HTML, field substitutions and context values. To edit the body’s HTML directly, select the source-code button on the editor toolbar.

| Substitution | Example | Behaviour |
|---|---|---|
| Field of the record | ${current.ShortDescription()} |
Shows the field’s value. An empty field shows nothing. |
| Field of a related record | ${current.Requestor().Manager()} |
Shows nothing if any reference on the way is empty |
| Journal field | ${current.ClientJournal()} |
Shows only the latest entry, or nothing |
| Context value | ${requestor_mobile} |
Shows the value the context script returned under that name |
| Script context | ${context.emailSubject} |
Shows a value passed by the script that sent the notification |
Context script
A context script runs before the message is built and returns named values for the subject and body.
let requestor = current.Requestor();
answer = {
requestor_mobile: requestor.Mobile.hasValue() ? requestor.Mobile() : "User does not have a mobile"
};

Link back to the record
getLinkForUI returns a link that opens the record in the named aspect, here SelfService.
answer = {
record_url: current.getLinkForUI({create: false, aspect: "SelfService"})
};
Then use the value in the HTML body:
<p><a href="${record_url}">View the ticket</a></p>
Attachments
To attach files, return an attachmentIds array of Attachment record IDs from the context script. Keep any other values in the same object.
const pdfIds = current.Attachments()
.filter(rec => rec.MimeType().endsWith("pdf"))
.map(rec => rec.getID());
answer = {
attachmentIds: pdfIds
};
| Property | Default | Behaviour |
|---|---|---|
notification.email.add.inline.attachments |
false | When true, attachment links in the body, other than images, also attach the file to the email |
Scripted notifications and context
A trigger, workflow or job can send a notification with OutboundNotification.processDirectOutboundNotification. The optional context object is available to every script field and substitution as context.
let notificationRec = Table("OutboundNotification")
.EQUAL("Name", "Incident - Has been resolved")
.query();
if (notificationRec.next()) {
OutboundNotification.processDirectOutboundNotification(notificationRec, current, {
context: {
emailRecipients: [current.Requestor()],
emailSubject: current.Number(),
bodyIntro: "Your incident has been resolved."
}
});
}
current is the record the notification runs for. In a job, query any record and pass it instead. The notification’s scripts then read the context:
| Field | Script |
|---|---|
| Recipients | answer = context.emailRecipients; |
| Messaging account | answer = context.messagingAccount; |
| From | answer = context.fromAddress; |
| Context script | answer = { texttosay: context.bodyIntro }; |
| Subject | Incident ${context.emailSubject} updated |