Replacement for javascript alert

Rahul Kathuria
Tera Expert

Hi All,

We are using standard javascript(underlined) alert which gives the below pop up message when i click on certain application. Is there any way i can make this pop up message more fancier, it should look good and i want to insert my company's logo in the popup message. I am currently on Eureka version.

    for(var j = 0; j< selectedOptions.length; j++){

    if(selectedOptions[j].value == '8ed97438d8121a40c64c9be40e87a4b8'){//check for Consultant Pharmacist Package

  moveSelectedOptions(selectedIDs, rightBucket, leftBucket); //move the options

  alert("Selecting this option will move certain Applications to Right side bucket as a Package.");  //remove none option from right

find_real_file.png

1 ACCEPTED SOLUTION

Here are the steps to install SweetAlerts (just tested it in my developer instance):



  1. Download SweetAlerts from ServiceNow Share (you'll need to login with your HI credentials / register if you've never used it before)
    1. The file saved will be called: SweetAlerts-V1.1.XML
  2. Once you have the XML file, you can import it from any table using the "Import XML" function in list view:
    1. I did this on "Retrieved Update Sets" since this is where the update set will appear after the import.
      1. ImportXML.png
    2. Once the file is imported, you will see a new entry on "Retrieved Update Sets" called "SweetAlerts-V1.2" in a state of "Loaded"
    3. Preview and Commit the Update Set. It will add 4 new items to your instance:
      1. Style Sheet (SweetAlert.css)
      2. Schedule Item (Share Install Logger) -- Marks that you've installed something from share, as to give the original author credit
      3. UI Script (globalsweetalerts)
      4. UI Script (SweetAlerts-min)



I tested this in a Geneva instance, but have used it in Fuji as well. Since its essentially Javascript hanging out in a UI Script, there shouldn't be any problems with it running in Eureka.


View solution in original post

7 REPLIES 7

mike_donathan
Kilo Guru

Rahul,



You can install SweetAlerts from ServiceNow Share:



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



Link Directly to Share:


ServiceNow Share



That will give you a lot more options on the look/feel of your alert boxes, including being able to insert a custom image into the alert. There's also a GitHub link below for the original code that outlines some of the cool things you can do (and has useful syntax examples):



SweetAlert


Rahul Kathuria
Tera Expert

Hi Mike,



Thanks. How can we install this sweetalert on my serviceNow webpage? i am currently on Eureka version.


Do we have any predefined steps?



Thanks,


Rahul kathuria


Here are the steps to install SweetAlerts (just tested it in my developer instance):



  1. Download SweetAlerts from ServiceNow Share (you'll need to login with your HI credentials / register if you've never used it before)
    1. The file saved will be called: SweetAlerts-V1.1.XML
  2. Once you have the XML file, you can import it from any table using the "Import XML" function in list view:
    1. I did this on "Retrieved Update Sets" since this is where the update set will appear after the import.
      1. ImportXML.png
    2. Once the file is imported, you will see a new entry on "Retrieved Update Sets" called "SweetAlerts-V1.2" in a state of "Loaded"
    3. Preview and Commit the Update Set. It will add 4 new items to your instance:
      1. Style Sheet (SweetAlert.css)
      2. Schedule Item (Share Install Logger) -- Marks that you've installed something from share, as to give the original author credit
      3. UI Script (globalsweetalerts)
      4. UI Script (SweetAlerts-min)



I tested this in a Geneva instance, but have used it in Fuji as well. Since its essentially Javascript hanging out in a UI Script, there shouldn't be any problems with it running in Eureka.


Hey MIke,


I installed this on my Geneva instance and for whatever reason, my console is not recognizing 'parent.swal':



Both UI Scripts are set to 'global>true'



Any tricks that I'm missing here? I can give you access to my dev instance if you want to take a look-


Thanks



Capture.PNG



I'm thinking this might be the culprit:


Snap1.jpg