Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

Kieran Anson
Kilo Patron

"Not waiting to press ok" - Are you using this in an onSubmit catalog client script and wanting to use the ok button to complete the submission

@Kieran Anson 

 

You got it right it is written on onSubmit script but i am not expecting it to be like complete the submission.

 

So based on the validation i am posting a message and want users to read it so thought of using spModal which is working but it is not waiting so for workaround i am using alert method

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();
			}
		}
	});
}