How to stop spModal.alert on service portal

shaik_irfan
Tera Guru

Hi,

 

I am using spModal.alert to pop-up a message which is working fine but the browser is not waiting to press Ok just like how alert method stops the submission.

 

Is there a way we can stop using spModal.alert

 
1 ACCEPTED SOLUTION

You can use something like the below, the "_hasConfirmed" value is added onto the g_form object to determine whether the user has gone through the process of accepting the prompt.

 

if(g_form._hasConfirmed == "undefined"){
	g_form._hasConfirmed == false;

	spModal.alert("Message here").then(function(answer){
		if(answer){
			g_form._hasConfirmed = true;
			if (typeof g_form.orderNow != 'undefined') {
				g_form.orderNow();
			} else {
				g_form.submit();
			}
		}
	});
}

View solution in original post

7 REPLIES 7

Anil Lande
Kilo Patron

Hi,

Can you please share Client controller script and how you are using it?

 

Thanks,

Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

I am using a Catalog Client Script:

 

spModal.alert('Thank you for submission!');

Hi,

Please check the documentation.

https://developer.servicenow.com/print_page.do?release=quebec&category=null&identifier=SPModal-API&m...

 

You need to use it like below:

spModal.alert('Thank you for submission!').then(function (answer) {
            //do nothing or write some code if needed
        });

 

Thanks,
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

@Anil Lande  Unfortunately it did not worked 😞 Seems it is not working for onSubmit catalog client script