Dialogs

servicenow

Enable AI Animation

What is the post about?
Notification Dialogs

What things would help with writing the post

UI Notification vs Notification Dialogs

To figure out what to use and when really is going to come down to each specific situation, but I’ll go through my thoughts on what these are, how to use them, and why I favor one over another.  To do this lets introduce our contenders.  On the left we have the quick and dirty, to the point, not always clean UI Notifications.  On the right we have the attention grabbing, mouse-taking, extensions exist to block Notification Dialogs.

UI Notifications, what they are and when to use them

By on the left I mean first.  So UI Notifications for me have been a progression for debugging.  I almost always use some sort of logging of UI Notification to test some problematic script.  Way back when I used alerts because Internet Explorer didn’t support console log for debugging but that was a long time ago. Then I used started using gs.addInfoMessage because it wasn’t as “In your face.”  Then Servicenow was nice enough to g_form.showFieldMsg. They had error and information styles.

The only UI Notifications in Servicenow are the following and are used these ways;

  1. gs.addInfoMessage (server) and gs.addErrorMessage (server)
  • When you have a message from the server, perhaps when the record is “Awaiting User Info” and you want it to be more clear, this can be done to show a message at the top of the screen.

  • client g_form.showFieldMsg()

  • When a field changes, you may clear the messages for the field, then check if it’s valid, if not, show a field message.

  • NotificationMessage (client)

    • This is what triggers when you change update sets.

Why are notification dialogs are important?

Using the right type of notification dialog is important to convey the message to your users. Most the time I believe these are just a distraction or waste of a click, however sometimes they are necessary to inform the user.  There are a log of these and you can make them look nice.  The issue with the

I also have used GlideDialogWindow, GlideWindow, and GlideModal in place of the alerts and confirmation messagebut they are all essentially the same except they work slightly differently.

Available notification dialogs today.

Examples of the notification dialogs.

  • spModal - Just a wrapper to uibModal
  • uibModal - uibModal
  • SweetAlerts - sweetAlert
  • GlideModal - glideModal
  • GlideWindow
  • GlideDialogWindow
  • Native - Alerts/Dialog/Confirm
  • AddInfoMessage
  • AddErrorMessage

Using the right type of dialog window is important to convey the message to your users. Most the time I believe any distraction or waste of a click. However sometimes as much as you recommend against sometimes you got to do things you don’t like. Like making a pop up window. Might as well make it look nice.

/scripts/classes/doctype/GlideModal.js

Any client-side library the browser needs -has to be shipped to the browser-. Now, by default ServiceNow will bundle these into -includes files and send them down all appended together, but we _also- put a marker in that gives you the original filename and where you can access it directly when we do that.

So you can use the ‘search all files’ feature of Chrome (or the equivalent in other browsers) to find references to what you’re interested in. When you find the definition of said thing, see if it’s in an _includes.js file

If so, scroll up to the closest Resources tag, and it should tell you where to go find that file by itself.
In this case, I loaded the Incident form, and found the definition in js_includes_last_doctype.js (edited)
So I just scrolled up a tiny bit and got the direct URL out of the _includes file
If the modal is just going to submit to an existing form, you could use GlideModalForm instead (that takes a title, a table name, and a callback for when the submit is successful) and that handles closing the modal and whatnot for you.


View this page on GitHub.