SP Modal Confirmation Pop-up Upon submission of request in the Service Portal

Mark L1
Tera Contributor

Hi Experts!

I am still a bit of a novice in terms of using SP Modal and the Service Portal. I hope you someone from the group can assist me in terms of creating an On Submit SP Modal confirmation pop-up that would stop the form from submitting before it sends out the request. 

I was able to create a basic one using an On Submit Catalog Client Script but the SP Modal confirmation does not stop the request from being submitted and it still submits the request even if the user hasn't clicked on either "OK" or "Cancel". Does any have a suggestion regarding this?

var flag = 'false';
var message = g_form.getValue('message');
if (typeof spModal != 'undefined')
{
spModal.confirm("Please confirm if the message is correct: " + message).then(function(confirmed)
{
flag = 'true';
});
}
if (flag != 'true')
{
return "false";
}
}

6 REPLIES 6

SanjivMeher
Kilo Patron
Kilo Patron

Why dont you use confirm?

 

function onSubmit() {

      var message = g_form.getValue('message');

      return confirm("Please confirm if the message is correct: " + message);

}


Please mark this response as correct or helpful if it assisted you with your question.

Mark L1
Tera Contributor

Thanks for the suggestion Sanjiv! I've considered that but our stakeholder would want a more customized approach to it hence we've considered using SP Modals. I guess the challenge here is that whenever the confirmation message shows up the requests still gets submitted even if the response from the confirmation modal has not been selected yet.


var message = g_form.getValue('message');

if (typeof spModal != 'undefined')
{
spModal.confirm("Please confirm if the message is correct: " + message).then(function(confirmed)
{
g_form.submit();
});

return false;
}


}

 

try this!!

Mark L1
Tera Contributor

Thanks Satheesh it works! Just one last thing, the modal gets stuck in front even if you press 'OK' and the form still does not submit.