Pavankumar_1
Mega Patron

This article will help to setup the push notifications for Agent App.

Follow below steps.

1. Create applet on the mobile studio under ITSM Mobile Agent or your scoped application.

Pavankumar4_0-1669808304525.png

After creation of applet get the sysid of applet go the sys_sg_screen table list or click System Mobile> Screens module and filter name with  Applet name+ Record Screen.

2. Go the Record Screen of your applet and copy sys_id and will provide this sys_id on Push Message Content script on DocumentId variable.

Pavankumar4_1-1669808389958.png

3. Create Push message content go to the system Notification> Push> Push Message Content.

Pavankumar4_2-1669808477054.png

4. On new form give name and select ServiceNow Mobile Application on Push app field.

 use below script and replace applet record screen sysid on DocumentId.

(function buildJSON( /*GlideRecord*/ current, /*String*/ message, /*Object*/ attributes) {
    var layoutFieldGenerator = new global.NotificationLayoutFieldGenerator();
    var identifier = layoutFieldGenerator.layoutField(current.sys_class_name, current.sys_id, "number");
    var description = layoutFieldGenerator.layoutField(current.sys_class_name, current.sys_id, "short_description");
    var state = layoutFieldGenerator.layoutField(current.sys_class_name, current.sys_id, "state");
    var json = {};
    json = {
        "aps": {
            "sound": "default"
        },
        "Redirection": {
            "Title": gs.getMessage("New Incident ASssigned"),
            "To": "Embedded",
            "Destination": {
                "DocumentId": "8f5f07a89757111051cb341e6253af2c", //need to give the applet form screen sysid
                "ItemId": current.sys_id
            },
            "Context": {
                "ContextType": "RECORD",
                "TableName": current.sys_class_name,
                "RecordId": current.sys_id
            }
        },
        "Layout": {
            "Status": state,
            "Identifier": identifier,
            "Description": description
        }
    };
    return json;
})(current, message, attributes);

5. Go to system Notification> Push> Push Messages and Create the Push Message.

   Select the Push app and Table and Push content which created above.

  Give the Message as per your need and use ${fieldname} to get the value.

Pavankumar4_3-1669808790158.png

6. After Creation of Push message then create notification on the same table and give the conditions on When to Send tab and provide users on who will receive tab and What to send add Push Message which created before.

Note: you can Set notification view as Push Notification View.

Refer below screen

Pavankumar4_4-1669808862765.png

7. Now go the System Notification > Push > Push Application and open the ServiceNow Mobile Application

Pavankumar4_5-1669808894978.png

8. Under related Push Default Registrations and click new and select add notification which created on step 6.

Refer below

Pavankumar4_6-1669809134391.png

9. Output

Pavankumar4_7-1669809185219.png
 
Please comment below if you have any questions. 
Comments
Eric148
Tera Guru

@Pavankumar_1, any tips for troubleshooting?  I am trying to get this to work for Catalog Tasks (sc_task) but have not been able to generate any push notification.   We have other working notifications that our implementers set us up with that I have checked against, but can't find where my problem is.

 

Everything is set up in the ITSM Mobile Agent application scope.

I have the correct sys_id from 

I have tried using existing notifications and creating new ones.  I have also tried the default Push Message Content from SN's docs.

 

(function buildJSON(/*GlideRecord*/ current, /*String*/ message, /*Object*/ attributes) {

    var layoutFieldGenerator = new global.NotificationLayoutFieldGenerator();
    var identifier = layoutFieldGenerator.layoutField(current.sys_class_name, current.sys_id, "number");
    var description = layoutFieldGenerator.layoutField(current.sys_class_name, current.sys_id, "short_description");
    var status = layoutFieldGenerator.layoutField(current.sys_class_name, current.sys_id, "priority");
    var json = {};
	var deepLinkGenerator = new global.MobileDeepLinkGenerator("Agent");
    var link = deepLinkGenerator.getFormScreenLink('ef58125cb7033300295a9489de11a988', current.getTableName(), current.getValue("sys_id"));
    json = {
        "aps" : {
            "sound" : "default"
        },
        "Link": link,
        "Layout" : {
            "Status": status,
            "Identifier" : identifier,
            "Description" : description
        }
    };
    
    return json;
    
})(current, message, attributes);

 

Any thoughts?  

AbuHaidar61
Tera Contributor

This is really helpful.

Satheesh12
Tera Explorer

@Pavankumar_1  Is this still valid? I no longer see a concept of applet while configuring  a mobile app, can you please guide me the table name?

Eric148
Tera Guru

@Satheesh12 - I checked my notes and this is the table I had listed for my applet record screen:

 

sys_sg_form_screen

 

I hope this helps,

navneetkach
Tera Explorer

how to open notification tab/screen [open sys_sg_notifications_tab] from icon section? is it possible to open it from icon ?

Version history
Last update:
‎11-30-2022 04:12 AM
Updated by:
Contributors