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:49 AM
Thx Andrew. That explains everything. Yes, I am using the confirm functionality of JavaScript. Looking forward to when you are able to get that piece into alertNow. Great work. Looks so much better than the standard alert boxes.
Stanley Martin
ServiceNow Developer
Epiq
Corporate Services
Phone: 913-621-9824
Cell: 913-216-1031
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2016 06:53 PM
andrew.lawlor Thanks for this awesome utility , is there any way we can call alertNow from server-side using a UI action may be?
I want to do something like similar ? below example is not working.
current.update();
alertNow({url: 'stats.do', title: 'New Incident Creation', header:'Thank You!', message: 'Your request has been submitted successfully.'});
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2016 06:02 AM
Andrew,
How do I get v2.0? when I go to ServiceNow Share site and seach for SweetAlert, the last version is 1.1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2016 10:47 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2020 12:09 PM
Quite an old post, but have been looking for various ways to improve the alerts in our instance and saw this.
All links to Share no longer work, and I don't see it on the new site when searching, so just wondering if it's still available somewhere?