The CreatorCon Call for Content is officially open! Get started here.

SweetAlert - a beautiful replacement for javascript's "alert"

Matt Saxton - G
Kilo Guru

 

SweetAlerts2 is out. 

 

SweetAlerts2

 

Hi Dev's,

 

Last night i was working on an application that needed some input. So i used SweetAlerts on the custom UI page and it turned out really nice looking, and i thought i could use globally!.

 

ServiceNow Share - SweetAlert

 

Once you install you can do any of the tests via the console

 

parent.swal({     title: "Are you sure?",     text: "You will not be able to recover this imaginary file!",     type: "warning",     showCancelButton: true,     confirmButtonColor: "#DD6B55",     confirmButtonText: "Yes, delete it!",     closeOnConfirm: false }, function(){     swal("Deleted!", "Your imaginary file has been deleted.", "success"); });

 

Make sure that you use "parent.swal()"

 

Here's more examples listed here SweetAlert

 

Screenshot's below.

 

2015-10-01 13_48_38-ServiceNow.png

 

2015-10-01 13_37_06-ServiceNow.png

44 REPLIES 44

Nitin,



The HTML tag in sweetalert is a Boolean attribute (true/false) that allows you to have HTML in the title / text area of the alert. Try setting HTML to true, then move your link text to the title and see if that works.


Hello Mike



Thanks for your response. I have set html to true and moved the link text to tittle but I see some errors in executing the code. Does title allows URL/links ?


find_real_file.png



Regards!


I have just tweaked the code again and have put the description and the link in the html tag and some other text in the tittle. Now it just prints the title and Ok button


Code:


find_real_file.png



Output


find_real_file.png


Regards!


Nitin_NOW
Tera Guru

Finally I figured this out by setting html as true and my link and information in Text.


find_real_file.png



I can now see the pop up with the URL/link as well. Unfortunately this feature is not working in Service portal. I have posted the same issue in other thread but did not receive any response yet. So just checking is there anything we have to do to make this working in SP?



Any thoughts are greatly appreciated.



REgards!


You can enable a UI script in Service Portal by adding it to the theme you are using, which is probably "Stock". Follow these steps:


  1. Go to Service Portal | Themes
  2. Click your theme being used for SP. Most likely Stock
  3. Click New in the JS Includes related list. If you don't see this related list, add it.
  4. Enter "globalsweetalerts" in the UI script and give it a name.
  5. Refresh and SweetAlerts should work in SP now