
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2019 05:48 AM
In the service portal we would like to start using Modals instead of alerts. One issue I'm having is when I write a script like this:
function onSubmit() {
if (typeof spModal != 'undefined') {
spModal.open({
message: 'Hello',
title: ''
});
} else {
var gm = new GlideModal();
gm.setTitle('');
gm.renderWithContent('Hello');
}
}
In the service portal after pushing submit, the form will submit after a few seconds without the user having pushed ok or closing the modal.
Is there any way to get it to perform more like an alert, requiring the modal to be closed before it submits and moves on to the next page?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2019 11:46 AM
I have finally solved this problem by using g_scratchpad
if (typeof spModal != 'undefined') {
if (g_scratchpad.isFormValid) {
return true;
}
spModal.open({
message: 'HELLO',
title: ''
}).then(function(confirmed){
g_scratchpad.isFormValid = true;
var actionName = g_form.getActionName();
g_form.submit(actionName);
return true;});
g_scratchpad.isFormValid = false;
return false;
} else {
var gm = new GlideModal();
gm.setTitle('');
gm.renderWithContent('HELLO');
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2019 06:23 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2019 07:05 AM
Hi Brandon,
Neither of the solutions listed in that thread works. The form still submits before the user has pushed Ok.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2019 07:10 AM
Ah apologies, I will ask around, and if I get a decent answer will return!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2019 11:46 AM
I have finally solved this problem by using g_scratchpad
if (typeof spModal != 'undefined') {
if (g_scratchpad.isFormValid) {
return true;
}
spModal.open({
message: 'HELLO',
title: ''
}).then(function(confirmed){
g_scratchpad.isFormValid = true;
var actionName = g_form.getActionName();
g_form.submit(actionName);
return true;});
g_scratchpad.isFormValid = false;
return false;
} else {
var gm = new GlideModal();
gm.setTitle('');
gm.renderWithContent('HELLO');
}