Sweet alert for Onsubmit client Script

Sindhu M
Tera Expert

Hi,

I am trying to display alert using swal onsubmit client script. I tried the below code. But the issue is, it popup the message and stayed for 10 to 15 seconds and disappears.

function onSubmit() {
swal({
title: 'Message',
html: true,
width:'100px',
text: 'Please: <a href = "www.google.com" target="_blank">Click here</a>',

});

}

So, I modified the code as below which doesn't submit at all even 'OK' is clicked

function onSubmit() {
swal({
title: 'Message',
html: true,
width:'100px',
text: 'Please: <a href = "www.google.com" target="_blank">Click here</a>',

},function(){
});

}

I am looking for something alert stays up until 'OK' is clicked and submit the form.

Did anyone try this before? Please let me know

9 REPLIES 9

Tim Deniston
Mega Sage
Mega Sage

You have discovered the fatal flow of SweetAlerts in ServiceNow (at least unless ServiceNow implements it natively). See these links for some discussion: 

 

https://share.servicenow.com/app.do#/detailV2/ef0129de45b642007c39bada468d18f3/comments

 

https://community.servicenow.com/community?id=community_question&sys_id=c3d6cba5db1cdbc01dcaf3231f96195c&view_source=searchResult

Saai1
Tera Expert

Hi Sindhu,


Try this:

function onSubmit() {
swal({
title: 'Message',
html: true,
width:'100px',
text: 'Please: <a href = "www.google.com" target="_blank">Click here</a>',
confirmButtonText: 'OK',

});

}

Saai1
Tera Expert

Hi Sindhu,

 

Try adding this line to your code at the end.

confirmButtonText: 'OK',

sethivarun
Kilo Guru

try this https://stackoverflow.com/questions/29945646/sweet-alert-timer-done-function

rksnow
Tera Expert

Hi, Do you happen to have any solution for this? I am looking for the same. Please let me know. Thank you.