Enable users to alert their contacts, through the use push notifications, that they
are mentioned in a thread. The user enters the @ character followed by the
contact's name in a record's activity stream, for their contact to be alerted.
Before you begin
Role required: admin
Procedure
-
Create the push notification message content, which defines where you are
pushing the notification to.
-
Navigate to in the filter navigator.
-
In the Push Notification Message Content form, select
New.
-
On the form, fill in the fields.
Table 1. Push Notification Message Content form
|
|
| Name |
Name of your push message content record. This
name is not visible to your users. |
| Application |
Scoped application associated with this record.
This field defaults to the current
application. |
| Push app |
Mobile app that uses your push notification.
- Enter ServiceNow Mobile
Application for the Mobile Agent app.
- Enter ServiceNow Request
Application for the Now Mobile app.
|
-
In the Push Message Generation field, copy the
following sample JSON code and paste it in the field.
(function buildJSON(/*GlideRecord*/ current, /*String*/ message, /*Object*/ attributes) {
var layoutFieldGenerator = new global.NotificationLayoutFieldGenerator();
var json = {};
var deepLinkGenerator = new global.MobileDeepLinkGenerator("<client type>");
var link = deepLinkGenerator.getFormScreenLink('<form_screen_sys_id>', current.getValue("table"), current.getValue("document"));
json = {
"aps" : {
"sound" : "default"
},
"Link": link
};
return json;
})(current, message, attributes);
Customize the values in the code:
- Locate the sys_id of the record screen by right-clicking on the screen
name and selecting Copy sys_id.
- Replace the
<form_screen_sys_id> portion
of the code with the sys_id.
- Define a client type in the variable
global.MobileDeepLinkGenerator Possible
values are:
-
Select Submit.
-
Create a message for the user's contacts to receive when they are mentioned in
a record's activity stream.
-
Navigate to .
-
In the Push Notification Message form, select
New.
-
On the form, fill in the fields.
Table 2. Push Notification Message form
|
|
| Name |
Name of your push message content record. This
name is not visible to your users. |
| Application |
Scoped application associated with this record.
This field defaults to the current
application. |
| Push app |
Mobile app that uses your push
notification.Note: Make sure to enter the same
mobile app entered in the Push
app field in the Push Notification
Message Content form. |
| Push Message Content |
Select the push message content you
created. |
| Table |
Table containing the records relating to your
notification. Select
live_notification. |
| Message |
Message that appears to the user's contacts,
informing them they are mentioned. |
-
Select Submit.
-
Create the push notification and define when to send it, who receives it, and
what it contains.
-
Navigate to .
-
In the Push Notification view form, select
New.
-
On the form, fill in the fields.
Table 3. Push notification view form
| Field |
Description |
| Name |
Name of your push notification. This name is not
visible to your users. |
| Active |
Option for determining whether the push
notification is active. Select this option. |
| Table |
Table containing the records relating to your
notification. Select the same table as the push
notification view form,
live_notification. |
| Push Message Only |
Option that determines whether to send a push
notification to a mobile device. This field is
automatically selected and is read-only by
default. |
| Category |
Category to which this notification belongs. A
category identifies and groups related
notifications. This category defines which actions
are available in the push notification. |
-
Select the When to send tab and then select
Inserted.
-
Select the Who will receive tab and then select
the lock icon (
) in the Users/Groups in fields.
-
Move User to the selected list.
Note: If the notification is addressed to a user with an inactive record
in the User [sys_user] table, the notification is not sent.
-
Select the What to send tab and select the lock
icon (
) next to the Push Messages field.
-
Select the reference lookup icon (
) to open the Push Notification Messages page.
-
Select the push notification message you created.
The push notification is listed as one of the available messages in the What to send tab.
-
Select Submit.
-
Enable your mobile app settings for notifications.
-
Select the Settings icon (
) and select the Notifications
tab.
-
Verify that Allow Notifications is enabled.
-
Verify that the mobile app you selected to receive notifications is
enabled by noting the setting of either the ServiceNow Mobile
Application or ServiceNow Request
application field.