Is there a way to keep an spModal window from closing after "cancel" or "submit" button is clicked?

Stephen31
Kilo Expert

I have a spModal being called in another widget on a the service portal.  When someone clicks the a button it performs a cancel or confirmed function.  However it also needs to validate prior to running the confirmed function if it meets the requirements to perform that function (has a valid change).

That is all working just great, as is what happens if they do not have a valid change with one exception.

If they did not select a valid change from a drop down and hit the confirm option(accept/submit), I want to give them an alert and keep the spModal window they are currently on open.  But it seems that no matter what, it wants to close the window.  Not seeing anything useful in documentation or community forums that would explain how to keep it from closing.

 

spModal.open({
				title: "Decommission",
				buttons: [{'label':'Cancel'},{'label': 'Accept','primary':true}],	
				backdrop: 'static',
				widget: 'devdecom',
				widgetInput:{ds_sys_id:space_id, app_sys_id:currentApp, subProd:false}
				 
			}).then(function(confirmed){

				if(confirmed.label=='Cancel'){
					c.data.dsoperation="";
					space_id="";
					changeSysID='';
					changeNumber='';
					c.data.changeSysID='';
					c.data.changeNumber='';
					$('input[id=space_id]').attr('checked', false);
				}
				else if(confirmed.label=='Accept'){
				
					if(c.data.changeSysID||appType=='Business'){
//script continues to open another modal, etc.
1 ACCEPTED SOLUTION

Willem
Giga Sage
Giga Sage

No that is not possible. the ".then(function(confirmed){"  is executed after the modal is closed. So the user presses the Cancel or Submit button. It will close the spModal and then run the .then code.

 

As a workaround you can consider to reopen the modal/open new modal in the .then part if they did not select a valid change from a drop down.

View solution in original post

1 REPLY 1

Willem
Giga Sage
Giga Sage

No that is not possible. the ".then(function(confirmed){"  is executed after the modal is closed. So the user presses the Cancel or Submit button. It will close the spModal and then run the .then code.

 

As a workaround you can consider to reopen the modal/open new modal in the .then part if they did not select a valid change from a drop down.