Notification variables

  • Release version: Yokohama
  • Updated January 30, 2025
  • 2 minutes to read
  • Summarize
    Summarized using AI
    This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.

    Summary of Notification variables

    Notification variables in ServiceNow enable you to insert dynamic content into the body of notifications, such as field values, record links, images, and system preferences links. This functionality helps tailor notifications to specific records and user contexts, improving communication and user experience.

    Show full answer Show less

    Syntax and Usage

    Variables use the syntax ${variable-name+variable-parameters}, where variable-name is required and variable-parameters are optional depending on the variable. Not all variables support parameters.

    Key Notification Variables

    • ${field-name}: Displays the value of a specific field from a record.
    • ${image-field-name}: Displays an image associated with a record, typically used within HTML image tags.
    • ${URI} and ${URIREF}: Create links to the current record with link text as "LINK" or the record's display value, respectively. Note: These do not apply to Workspace records.
    • ${reference-field.URI} and ${reference-field.URIREF}: Create links to records referenced by a field, with similar link text options.
    • ${CMSURI}: Generates links to specific CMS pages using relative paths.
    • ${notification:body}: Inserts the body content of an email template or notification into an email layout.
    • ${mailscript:script-name}: Executes a specified mail script.
    • ${NOTIFUNSUB}: Displays an unsubscribe link for the notification, with customizable link text.
    • ${NOTIFPREFS}: Displays a link to notification preferences, with customizable link text.
    • ${comments:n}: Shows the most recent n comments on the target record; omitting n shows all comments.
    • ${commentsandworknotes:n}: Shows the most recent n comments and work notes; omitting n shows all.

    Practical Application

    Using these variables, ServiceNow customers can customize notifications to include contextual data such as direct links to records, recent comments, images, or user preference options. This enhances notification relevance and user engagement.

    Important Notes

    • Links generated by ${URI} and ${URIREF} do not work for records in Workspace; instead, use mail scripts to generate Workspace URLs.
    • Parameters like sysparmscriptlet or sysparmview can be used with URI variables to customize link behavior.

    Examples

    • ${number} outputs the incident number, e.g., "Incident INC1000001 - comments added".
    • Using <img src='${picture}?t=medium'/> displays an image associated with a record.
    • ${URI} and ${URIREF} create clickable links within notification text.
    • ${CMSURI+ess/incidentdetail} creates a link to a CMS page on the ServiceNow instance.

    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.

    Syntax

    Specify a notification variable using this syntax:

    ${variable-name+variable-parameters}

    The variable-name portion is always required. Not all notification variables support the variable-parameters portion. When available, most variable parameters are optional. See the list of available notification variables for variable names and available parameters.

    Available variables

    The system provides these notification variables.

    Table 1. Available notification variables
    Variable Description Available parameters
    ${field-name} Display the value of the specified field. None
    ${image-field-name} Display an image associated with a record. This variable is typically used with HTML to specify the source of an image element. None
    • ${URI}
    • ${URI_REF}
    Display a link to the current record.
    • URI: The link text is the word LINK.
    • URI_REF: The link text is the display value of the record.
    Note:
    These variables don't apply to records in Workspace. To link to a record in Workspace, create a mail script that prints a URL to a notification. For more information, see Linking to a record in Workspace.
    Any valid sysparm URL parameter. For example:
    • sysparm_scriptlet
    • sysparm_view
    • ${reference-field.URI}
    • ${reference-field.URI_REF}
    Display a link to the record listed in a reference field.
    • URI: The link text is the word LINK
    • URI_REF: The link text is the display value of the record.
    Any valid sysparm URL parameter. For example:
    • sysparm_scriptlet
    • sysparm_view
    ${CMS_URI} Display a link to the specified record within a CMS page. <CMS-site>/<CMS-page>: The required relative path to the CMS page.
    ${notification:body} Display the body contents of an email template or email notification. Use this notification variable to specify where to display body content in an email layout. None
    ${mail_script:script-name} Run the specified mail script. None
    ${NOTIF_UNSUB} Display a link unsubscribe from this notification. link_text: specify the text to display as a link within quotation marks.
    ${NOTIF_PREFS} Display a link to set notification preferences. link_text: specify the text to display as a link within quotation marks.
    ${comments:n}

    Display the most recent comments that were made on the target record. The number of comments to display is n. For example, ${comments:3} displays the last three comments that were made to the record.

    To display all comments, use the variable ${comments}.

    Any number greater than 0.
    ${comments_and_work_notes:n}

    Display the most recent comments and work notes that were made on the target record. The number of comments and work notes to display is n. For example, ${comments_and_work_notes:3} displays the last three comments and work notes that were made to the record.

    To display all comments and work notes, use the variable ${comments_and_work_notes}.

    Any number greater than 0.

    Examples

    Refer to the following examples to see how each notification variable is rendered in the output:
    Variable Example
    ${field-name}

    Source: Incident ${number} - comments added

    Output: Incident INC1000001 - comments added

    ${image-field-name}

    Source: <img src='${picture}?t=medium'/>

    Output:notification image variable

    • ${URI}
    • ${URI_REF}

    ${URI} Source: Click here to view incident: ${URI}

    ${URI} Output: Example that shows how the link text word Link serves as the link to the current record

    ${URI_REF} Source: Click here to view incident: ${URI_REF}

    ${URI_REF} Output: Example that shows how the link text displayed is the value of the record

    • ${reference-field.URI}
    • ${reference-field.URI_REF}
    Source:
    Click here to view Incident: ${URI_REF}
    Click here to view Related Problem: ${problem_id.URI_REF}

    Output: Example that shows a link to a record listed in a reference field

    ${CMS_URI}

    Source: ${CMS_URI+ess/incident_detail}

    Output: a link to a target CMS page such as https://<instance name>.service-now.com/ess/incident_detail.do?sysparm_document_key=incident,46e18c0fa9fe19810066a0083f76bd56

    ${notification:body}

    Source: How a variable for the email body works in an email layout.

    Output:How the variable for the link to notification preferences works.

    ${mail_script:script-name}
    ${NOTIF_UNSUB}
    ${NOTIF_PREFS}