Create push message content

  • Release version: Washingtondc
  • Updated February 1, 2024
  • 2 minutes to read
  • Push message content specifies additional JSON content in the push notification payload that is sent to the push provider.

    Before you begin

    You must know how to use JSON with push messages.

    Role required: admin or push_admin

    Note:
    This process describes configuration used in the ServiceNow mobile app. Push Notification configuration for the current ServiceNow mobile UI can be found at Mobile push notifications

    About this task

    Push message content defines the style of push notification that can be sent out for your custom app. You can add custom content, such as a picture, icons, or action buttons for the user to respond to the notification. Use the following variables in the script:
    • current: properties of the current record.
    • message: push message sent as the body of the entire push content.
    • attributes: object of the push message attributes that you define.

    Procedure

    1. Navigate to All > System Notification > Push > Push Message Content.
    2. In the Push Notification Message Contents table, click New.
    3. Fill out the fields on the Push Notifications Message Content form (see table).
    4. Click Submit.
      Adding content with JSON
      Table 1. Notification Message form fields
      Field Description
      Name Enter a descriptive name for the message content.
      Push app The push application the content can be used with.
      Push Message Generation Enter a script that determines the message content. See the example scripts.
      Related list
      Push Message Attribute Definitions Select the attributes that apply to this notification. Attributes can be a value or an action. These attributes are used as default values for the content items you create in the content script. However, any attributes you create with the push message can override these attributes. See Create a push message attribute definition for information on creating attributes.

    Example

    The following is an example of a content record that creates a two-button layout, one to approve something, such as a change request, and one to decline it.

    
    var json = { 
      "table" : current.getTableName(), 
      "sys_id" : current.sys_id, 
      "template" : { 
        "type": "2 button", 
        "button1" : { 
          "title" : "Approve", 
          "action" : attributes.button_action, 
          "parameters" : { 
            "response" : "approve" 
           } 
         }, 
         "button2" : { 
           "title" : "Decline", 
           "action" : attributes.button_action, 
           "parameters" : { "response" : "decline" 
           } 
         } 
       } 
    }; 
    json;

    What to do next

    Define a push message attribute to specify a default push action script or string that you can use in the push message content.