Advanced email setup
Advanced conditions for email notifications:
To send a notification using an advanced condition, you can:
- Call a function that returns a value, or
- Set the global variable answer using a script
(function() {
var groupMember = gs.getUser();
return !groupMember.isMemberOf(‘XYZ’);
})();
Edit HTML content in an email notification
Open any existing notification and go to “What it will contain”
In the Message HTML field, click the source code icon (<>) to open the HTML source code editor
Document attachments on an email notification
We can attach documents and reports to email notifications by scripting or linking to the sys ID of the record.
- To include all attachments from the source record, select the check box for the Include attachments field.
- Add attachment link to email use: “${mail_script:attach_links}”
- Attaching reports using the Sys ID: “${report:A:B}”
- Where :
- A is the type of report you want to attach (reportID, gaugeID, dashboardID, or chartID).
- B is the sys ID of the report, gauge, dashboard, or chart to be attached.
- For example:
- ${report:reportID:<xyz12345>}
- ${report:gaugeID:< xyz12345>}
- ${report:dashboardID:< xyz12345>}
- ${report:chartID:< xyz12345>}
Note: Multilevel pivot reports can’t attach to email notifications.
Preview email notifications
You can preview what notifications look like before you actually enable the instance to send them.
Time zone for email notifications
A system property controls the time zone that the instance uses for the date and time stamp of a message.
The date and time stamp of a notification uses the system time zone and it is handled by property called “glide.email.append.timezone ”
Specify alternative outbound email addresses for notifications
By default, the system sends all outbound email notifications from the default email address of the instance, but you can specify an alternative address.
Specify an outbound email address for a particular language
We can specify a different email address for each language your instance supports.
Open any notification and go to What will it contain section, enter a new email address in the From field.
Go to When to send section, create a condition with Assigned To -> User – > Language and choose language with Is Operator.
Notification variables
Use notification variables to display dynamic information in the body of a notification such as a field value, a link to a record, or a link to system preferences.
Examples
Below examples to see how each notification variable is rendered in the output:
- ${field-name}:
- Source: Incident ${number} – comments added
- Output: Incident MYINC0001128 – comments added
- ${URI}: View incident: ${URI}: View incident: LINK
- ${URI_REF}: View incident: ${URI_REF}: View incident: MYINC0001128
- ${reference-field.URI}: View Cause by change-({u_cause_by_change.URI}) : LINK
- ${reference-field.URI_REF}: View Cause by change-({u_cause_by_change.URI_REF}) : CHG0040007
- ${mail_script:script-name}: Add mail script to notification.
- Unsubscribe (${NOTIF_UNSUB}): Unsubscribe
- Manage Preference (${NOTIF_PREFS+link_text=”Manage Preference”}): Manage Preference
To copy attachment from one record to another record. GlideSysAttachment.copy('sourcetable','sys_id','destinationtable','sys_id');
Email templates
It enable you to create reusable content for the subject line and message body of email notifications.
Email layouts
Create reusable content for the message body of email templates.
- We can use email layouts to:
- Ensure all email notifications have a consistent layout such as always displaying a header, body, and footer.
- Display static content on all email notifications such as a company logo or a background.
- Declare inline styles available for use in the message body of an email template such as setting a text font, size, and color.
- Provide users with links to common response actions such as unsubscribe from a notification or manage notification preferences.
Watermarks on notification emails
By default, the system generates a watermark label at the bottom of each notification email to allow matching incoming email to existing records. Each watermark includes a random 20-character string that makes it unique.
Troubleshooting notification emails
Common Outbound Email Issue | Symptom | Solution | |
1 | Inactive user is locked out (Berlin or later releases). | A specific user stops receiving notifications. | Verify the user is not locked out because they are inactive. |
2 | User is locked out (Berlin or later releases). | A specific user stops receiving notifications. | Verify the user is not locked out. |
3 | User disabled notifications. | A specific user stops receiving notifications. | Verify the user’s notification preferences. |
4 | User preferences do not list active email device. | A specific user does not receive notifications or the instance fails to send a notification. | Verify the user has an active email device in their notification preferences. |
5 | Intended recipient does not have an email address. | A specific user does not receive notifications or the instance fails to send a notification. | Verify the intended recipient has an email address. |
6 | Intended recipient has improperly-formatted email address. | A specific user does not receive notifications or the instance fails to send a notification. | Verify the email address is formatted properly. |
7 | Option to notify event creator disabled. | A user receives some but not all notifications. | Verify notification set to notify the event creator. |
8 | Intended recipient has an active delegate. | The instance sends a notification to an unexpected user. | Verify the user who received the email is not a delegate of another user. |
9 | Notification variable values change after the events process job creates notifications. | The events process job creates multiple notifications that all have the same notification variable values. | Verify that the notification matches your business needs. |
10 | Attachments exceed maximum number or file size. (Not applicable to SMS notifications.) | Outgoing mail does not contain expected attachments. Can send some attachments, but not all. | Verify the attachments do not exceed configured maximums. |
11 | The instance is not enabled to send email. | The instance does not send any notifications at all. | Verify the instance is enabled to send email. |
12 | Instance does not have proper settings for custom SMTP server. | When using a custom SMTP server, no messages appear in the Outbox or Sent mailboxes. | Verify the instance has the proper custom SMTP server settings. |
13 | The notification’s required conditions are not met (Berlin or later releases). | The instance does not send notifications for a particular type of record or action. | Verify the notification record’s conditions met. |
14 | The SMTP sender scheduled job is in an error state. | The instance stops sending email notifications but there are messages in the Outbox. | Verify the SMTP Sender scheduled job is running. |
15 | The SMS sender scheduled job is in an error state. | The instance stops sending SMS notifications but there are messages in the Outbox. | Verify the SMS Sender scheduled job is running. |
16 | The notification’s required event is not being triggered (Aspen or earlier releases). | The instance does not send notifications for a particular type of record or action. | Verify the triggering action generated the notification event. |
17 | There is a routing problem on the outbound mail server. | The instance sends the mail, but the recipient never receives it. | Verify the outbound mail server received the email. |
Trigger email through event
Events are special records the system uses to log when certain conditions occur and to take some kind of action in response to the conditions.
The eventQueue() method is part of the GlideSystem server-side API. The eventQueue() method inserts an event in an event queue. The eventQueue() method is typically passed four parameters but can also take an optional 5th parameter:
- Event name. Enclose the event name in quotes.
- GlideRecord object, typically current but can be any GlideRecord object from the event’s table.
- Any value that resolves to a string. This is known as parm1 (Parameter 1). Can be a string, variable that resolves to a string, or method that resolves to a string.
- Any value that resolves to a string. This is known as parm2 (Parameter 2). Can be a string, variable that resolves to a string, or method that resolves to a string.
- (Optional) Name of the queue to manage the event.
- Example:
- gs.eventQueue(‘event.name’, GlideRecord, parm1, parm2); // standard form
Steps to create Event:
- Register an event in Event Registry.
- Create a business rule.
- Create an email notification and set Send when = “Event is fired” and select even which you have created.
Tables Used:-
- Event registry-sysevent_register
- Business Rule-sys_script
- Notification-sysevent_email_action