AlertNow - Share - JavaScript Alert Replacement
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2016 06:49 AM
I must say that I was highly impressed by sweet alert (which you can find here: ServiceNow Share ), which is amazing. I've always been bothered by just how bad the default JavaScript alert dialogs look compared to ServiceNow's actual UI. I wanted to introduce something similar, but without the need for importing a 3rd party library. As such, I created AlertNow, which is a wrapper for a native ServiceNow replacement for JavaScript's alert functionality. It uses a UI Page combined with ServiceNow's GlideModal class to elevate the user experience by replacing JavaScript's basic 'alert' functionality.
alertNow is a modular alert that is powered by ServiceNow's GlideModal class. There are several potential use cases:
1. Allows you to relay information to the user with a simple, attractive and configurable modal dialog based on a standard format.
2. Allows you to specify a URL for a server-side redirect after the dialog is closed, if desired.
How do I install it?
All you have to do is deploy the Update Set. After that, you can call AlertNow from any client-side script in the system.
How do I use it?
The parameters for AlertNow are easy - just pass it a native JavaScript object with some or all of the following properties:
You can provide either message or propName, but not both.
message - This is the content of the message body. Only plain text is allowed.
OR
propName - This parameter must contain the name of a sys_properties record in which you can specify a message. Use this if you would like to standardize your message using properties, or if you want to render HTML in your modal dialog, such as URLs. You can also specify additional styling in the property.
You may configure the font size of the main message with the following parameter:
fontSize - acceptable values are:
small
medium
large
x-large
Medium is the default size.
title - The title will display in the upper-left corner of the modal window.
header - This is the header that will display above the message body.
headerSize - You may specify the size of the header by passing one of the following values:
small
medium
large
Large is the default size.
image - An optional image to display above all text content. Simply pass the image URL. The size is based on the image's actual size by default.
imageWidth - allows you to specify the width of your image as a number.
imageHeight - allows you to specify the height of your image as a number.
url - An optional redirect URL. If present, the form will display both 'Ok' and 'Cancel' buttons. 'Cancel' will close the dialog, while 'Ok' will execute a redirect to your specified URL (server-side).
You may also omit either the cancel or OK buttons with the following parameters:
showCancel - boolean - true to show, false to hide. The default is true.
showOk - boolean - true to show, false to hide. The default is true.
You may call this alert from any client-side script in the system using:
alertNow(yourObject);
You can find AlertNow here: ServiceNow Share
Script examples:
alertNow({url: 'stats.do', message:'You must assign this task and update its Work notes before closing it.', header:'Task Not Closed', title:'My Title', image:'warning-shield.png'});
********************
alertNow({title:'Congratulations', header: 'Great Job!', message: 'Fantastic work. You submitted that form perfectly.', image: 'http://images.techtimes.com/data/images/full/163416/meaning-of-vault-boy-thumbs-up-jpg.jpg?w=600', imageHeight: '400', imageWidth: '200'});
********************
var myProperty = however you get properties via GlideAjax;
alertNow({propName: myProperty, header:'Contract Required', title:'My Title'});
Visual samples:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2016 08:50 AM
Nothing important here, just big props for Vault Boy!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2017 07:40 AM
Great tool. I love it. I've used it in a number of places so far. I did however find a spot where I couldn't use it. I'm validating an email field, and if the user inputs an invalid format I used alertNow to notify them. I then blank out the field and set focus back to that field. Using alertNow, the focus will not return to the field. I've tried at least a handful of different ways to get focus back and none have worked. If I go back to the default Javascript alert function, it works fine.
Just an FYI. Maybe you can come up with a way to resolve that.
Thx

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2017 07:54 AM
Andrew,
Is this compatible with the Service Portal?
I have a need to alert users on certain catalog items and this works great in the legacy UI, but does not display in the service portal.
Standard javascript alert() does work in both.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2017 04:50 AM
Steve,
Check with NewRocket, they have ServicePortal widgets for sale including an Alert that mirrors this functionality.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2017 05:32 AM
We just yesterday upgraded our Development Instance to Jakarta. Sure would be nice if ServiceNow would finally implement something like this OOB.