loop91 Header logo
Experiments

Quick experiment to show continuously updating clock on ServiceNow banner notifications/announcements

Kunal Khatri
#webdev#frontend#experiments#clock#banner#annoucements

The Ask ?

Create a persistent banner annoucement to show time critical + auto-updating details for all users. What we want is a way to show a piece of text for all users on servicenow interface. It must be auto-updating in real time. The user can be at any page on servicenow and they must be able to see this info.

Solution:

What we are suggesting that we create a Banner Annoucements [ docs link ]. It is a nifty tool to communicate with users. The announcement could be dismissable or not. Banner announcement can have multiple classes ( from info to critical alert) allowing for a nuanced approach.

We are going to use this, additionally we shall write a Scheduled Job to update the banner in real time. We are using an interval of 1 second since we are putting current time in the annoucenement text. But you could/should use appropriate time interval as per need.

Let’s start

  1. Create a new Banner Annoucement [ table : sys_ux_banner_announcement ]

    creating a new banner annoucment

    I’ve marked the announcement as Non-dismissable, you should decide your use case. Once saved, copy the sys_id of this record, we will need it for next step.

  2. Create a new Scheduled Job [ table : sysauto_script]

    creating a new Scheduled Job

    var announcement = new GlideRecord("sys_ux_banner_announcement");
    announcement.get("<sys_id from step 1>");
    
    var epoch = new GlideDateTime();
    
    announcement.heading = "loop91 - Tinkering with ServiceNow - " + epoch.getDisplayValue();
    announcement.update();

    Use the sys_id saved in step 1 on line 2 in given code.

    I’ve set the scheduled job to run every 1 second to update clock on the announcement every second. You should use appropriate time interval here to optimise the execution.

  3. That’s it. You have a continuously running clock on the banner announcement.

Some extra nuggets of info:

  1. When creating new Banner Announcement you need to set Announcement Configuration. I used pre-existing record for Unified Navigation. This configuration decided as to where would this announcement appear on servicneow. Configuring Announcement config
  2. If you are tinkering on your PDI, I would suggest marking the scheduled job as inactive when not in use.
← Back to Blog