---
title: "Notification recipients and content"
site: admin
version: 2027.1
versions: "all"
url: https://docs-new.servicely.ai/admin/2027.1/messaging/notification-recipients-and-content/
type: reference
application: system_email
last_updated: 2026-12-03
commit: 97a56b9c7df7
---


This page lists the script fields of an outbound notification, what each returns and what the subject and body can substitute. It is for readers who write those scripts, and you need the `administrator` role to edit them. [Outbound notifications](page:messaging/outbound-notifications) explains how a notification is sent.

## Script fields

Each script field is a server script that sets `answer`.

<!-- source: system_email/data/ScriptLibrary?Name=OutboundNotification, 2027.1.10 -->
| Field | Where it is | Sets `answer` to |
| --- | --- | --- |
| Condition | The notification | True to send. An empty script, or any other answer, does not send. |
| Recipients | The notification | An array of recipients. See **Recipient entries**. |
| Context script | The notification, and each provider configuration | An object of named values for the subject and body. |
| Messaging account | Each provider configuration. On a classic (v1) notification, the notification. | The record ID of a messaging account. |
| From | Each provider configuration. On a classic (v1) notification, the notification. | A sender address. |

When **Messaging account** or **From** sets nothing, Servicely calls `messagingAccount(record)` or `fromAddress(record)` in the `OutboundNotificationSupport` script library. Both return nothing by default. Edit them to choose the account and sender for every notification in one place. When they also return nothing, Servicely uses the default Email messaging account and its address. See [Script libraries](page:automation/scripts/script-libraries).

## Script variables

| Variable | Available in | Description |
| --- | --- | --- |
| `current` | Every script field and substitution | The record the notification is for. |
| `context` | Recipients, Context script, Messaging account, From and substitutions | The values a script passed when it sent the notification. An empty object otherwise. |
| `notification` | Context script and substitutions | The notification record. |
| `cc()`, `bcc()` | Recipients | Functions that mark a recipient entry as CC or BCC. |
| A name the context script returned | Substitutions | The value returned under that name. |

## Recipient entries

A recipients script puts any mix of these entries in its array. Servicely turns each into email addresses, drops invalid ones and removes duplicates. An address in the To list is removed from CC and BCC.

| Entry | Example | Resolves to |
| --- | --- | --- |
| Fixed address | `"servicedesk@example.com"` | That address. |
| Text field | `current.Email()` | The address in the field. |
| User reference | `current.Requestor()` | The user's email address. |
| Group reference | `current.AssignmentGroup()` | Each member's email address. |
| List of users | `current.relation("Follower")` | Each user's email address. |
| CC recipient | `cc(current.relation("Collaborator"))` | CC addresses. |
| BCC recipient | `bcc(current.Assignee())` | A BCC address. |

When **Send individually** is Yes, each To recipient gets a separate email, and every one of those emails carries the CC and BCC addresses.

## Substitutions

A subject and body are text with `${…}` substitutions. Each substitution holds a script expression, and Servicely puts its result in the message. An expression that fails or returns nothing shows nothing. On an Enhanced Notifications (v2) notification the subject and body are the **Subject** and **HTML Template** of the messaging template. On a classic (v1) notification they are the notification's **Subject** and **Body**.

| Substitution | Example | Shows |
| --- | --- | --- |
| Field of the record | `${current.ShortDescription()}` | The field's value. |
| Field of a related record | `${current.Requestor().Manager()}` | The related value, or nothing when a reference on the way is empty. |
| Context script value | `${header}` | The value the context script returned as `header`. |
| Value passed by a script | `${context.bodyIntro}` | The value the sending script passed as `bodyIntro`. |

<Image src="asset:screenshots/admin/messaging-notification-recipients-and-content/template-substitutions.png">The default messaging template "Work - with Summary & Client Journal", with ${subject} as its Subject and ${current.Number()} and ${header} substitutions in its HTML Template.</Image>

## Attachment setting

<!-- source: system_email/data/ApplicationProperty?Key=notification.email.add.inline.attachments, 2027.1.10 -->
| Setting | Property | Default | Effect |
| --- | --- | --- | --- |
| **Include inline images as attachments**, on the **Email** tab of **Email and notification settings** | `notification.email.add.inline.attachments` | No | When Yes, a link to an attachment in the body attaches that file to the email and no longer links to it. Images in the body are embedded in either case. |

## Examples

These examples use fields of the Incident table.

### Send to followers, the requester and the assignee

A **Recipients** script. It sends to the assignee, or to the whole assignment group when the incident has no assignee.

**Script**

```javascript
let toList = [
    current.relation("Follower"),
    current.Requestor(),
    current.RequestedFor(),
    current.Email()
];

if (current.Assignee()) {
    toList.push(current.Assignee());
} else {
    toList.push(current.AssignmentGroup());
}

answer = toList;
```

### Pass values to the template

A **Context script** for a template that holds `${subject}`, `${message}` and `${footer}`. `getLinkForUI` returns a link to the record. Its `aspect` option names the view the link opens, and the default notifications to requesters use `SelfService`.

**Script**

```javascript
answer = {
    subject: "Incident " + current.Number() + " has been resolved",
    message: "Your incident has been resolved and is awaiting your feedback.",
    footer: "Open it here: " + current.getLinkForUI({ aspect: "SelfService" })
};
```

### Attach files to the email

A **Context script** that returns `attachmentIds`, an array of the record IDs of attachments. Servicely copies those files to the email. Keep any other values in the same object.

**Script**

```javascript
const pdfIds = current.Attachments()
    .filter(rec => rec.MimeType() == "application/pdf")
    .map(rec => rec.getID());

answer = {
    attachmentIds: pdfIds
};
```

### Send a notification from a script

A trigger, workflow or job sends a notification with `OutboundNotification.processDirectOutboundNotification(notification, record, options)`. The call does not test the notification's **Active**, **Type** or **Condition**, so the script decides when to send. The `context` option reaches the notification's scripts and its template as `context`.

**Script**

```javascript
let notificationRec = Table("OutboundNotification")
    .EQUAL("Name", "Incident - Major incident declared")
    .EQUAL("Active", true)
    .query();

if (notificationRec.next()) {
    OutboundNotification.processDirectOutboundNotification(notificationRec, current, {
        context: {
            emailRecipients: [current.Requestor()],
            bodyIntro: "We are treating this as a major incident."
        }
    });
}
```

"Incident - Major incident declared" is an example name for a notification you create with **Type** set to Scripted. Its **Recipients** script is `answer = context.emailRecipients;`, and its template shows the text with `${context.bodyIntro}`. In a job, query the record and pass it in place of `current`. See [Table](page:api/scripting/records/table) in the API reference.

## Related

- [Outbound notifications](page:messaging/outbound-notifications)
- [Create an outbound notification](page:messaging/create-an-outbound-notification)
- [Classic (v1) notification fields](page:messaging/classic-notifications)
- [Script libraries](page:automation/scripts/script-libraries)
