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

function onSubmit() {
var message = "test";


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

return false;
}

}

 

try this

Barrilito van D
Kilo Guru

Hi,

User the modal function but return false if you want to cancel the submit. You seem to be returning the string "false" instead of a boolean value false (without the qoutes).

Regards!