Mark Roethof
Tera Patron
Tera Patron
 
Hi there,

 

Wouldn't it be an interesting idea to have annotations, info message or warning message alike in the Core UI? For example on a Form Lay-out, and dismissible by individual users? Just a random idea that popped up in my mind. While I don't have a use case for this at the moment for a customer, let's just build this and share it with Y'all. I didn't come up with all of it from the top my mind, turning instances inside out I came across functionality that contained bits and pieces of what was after.

 

Desired result

Let's first start with the idea I have in mind. For example on the Incident Form Lay-out, having a dismissible Info message like annotation. The dismissible annotation being user specific.

 

Note: By default there is an "X" on the right side of the annotation which obviously hides the annotation. Though after refreshing the browser the annotation will appear again. Our goal here is to really dismiss the annotation.

 

01.png

 

Approach

User Preference

Since the dismissible annotation should be user specific, my thought is to use the User Preferences functionality for this and avoiding the need to create a custom table to keep track of who has the annotation dismissed or not. If the user dismisses the annotation, a User Preference should be created that has the User field filled (with the logged in user) and a boolean value representing the annotation is dismissed.  

 

For this example, let's go for a User Preference with name "hide.incident.annotation" and if the value is "true" the annotation should be dismissed.

 

Client Script

In my thought the dismissible annotation should be client side and appear on load, therefore going for an onLoad Client Script. Within the script checking the User Preference and depending on its value/presence ending the script or displaying an Info Message that can be clicked to dismiss. If clicked the User Preference should be set.

 

02.png

 

Okay the script is not perfect, it would have been better to use a UI Message and format the message a bit better, though I will leave that up to you to improve 😄.

 

Script

function onLoad() {

    window.hidePolicyMessage = function() {
        setPreference('hide.incident.annotation', true, g_form.clearMessages);
    };

    var hideMessage = getPreference('hide.incident.annotation');
    if (hideMessage == 'true' || hideMessage == true) {
        return;
    }

    var dismissMessage = 'Click <a href="#" onclick="hidePolicyMessage();">here</a> if you don\'t want to see this message again.';

    var gwt = new GwtMessage();
    g_form.addInfoMessage(gwt.getMessage(dismissMessage));

}
---

 

That's it. Hope you like it. If any questions or remarks, let me know!

 

C

If this content helped you, I would appreciate it if you hit bookmark or mark it as helpful.

 

Interested in more Articles, Blogs, Videos, Podcasts, Share projects I shared/participated in?
- Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

 

Kind regards,


Mark Roethof

Independent ServiceNow Consultant
9x ServiceNow MVP

---

LinkedIn

Version history
Last update:
‎01-27-2025 10:52 PM
Updated by:
Contributors