onSubmit script g_modal popup saving form when popup appears
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2022 02:39 AM
Hello,
I have the following onSubmit client script, and it presents a modal popup for end users when conditions are met.
This is for native Ui and agent workspace.
Works fine in native, it prompts the user with modal and only submits form when user selects yes.
Whereas in workspace, when the modal popup appears the form saves at the same time.
How can I prevent the form from saving in workspace until the modal has not been actioned, i.e. yes/no selected.
here is my script for HR cases:
function onSubmit() {
var subjectPersonValue = g_form.getValue('subject_person');
var openedForValue = g_form.getValue('opened_for');
var openedFor = g_form.getControl('opened_for');
var url = top.location.href;
if (url.indexOf('workspace') <= -1) { // if using native UI run this code
if (openedFor.changed) {
if (subjectPersonValue == openedForValue) {
if (g_scratchpad._action_confirmed) {
return true;
}
// Render GlideModal window
var dialog = new GlideModal('glide_modal_confirm', false, 400);
dialog.setTitle(new GwtMessage().getMessage('Opened for Changed to Subject Person'));
dialog.setPreference('body', new GwtMessage().format("You have set the Opened For to the Subject Person, which will grant them access to view the Case - are you sure?"));
dialog.setPreference('focusTrap', true);
dialog.setPreference('onPromptComplete', doComplete);
dialog.setPreference('onPromptCancel', doCancel);
dialog.render();
return false;
function doComplete() {
g_scratchpad._action_confirmed = true;
gsftSubmit(null, g_form.getFormElement(), g_form.getActionName());
}
function doCancel() {
}
}
}
} else if (url.indexOf('workspace') > -1) { // if using workspace run this code
if (g_scratchpad.openedFor != g_form.getValue('opened_for')) { // If opened for value has changed
if (subjectPersonValue == openedForValue) {
// Render Modal window
var msg = "You have set the Opened For to the Subject Person, which will grant them access to view the Case - are you sure?";
g_modal.confirm(getMessage("Opened for Changed to Subject Person"), msg, function(confirmed) {
if (confirmed) {
g_form.save();
}
});
}
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2022 08:11 AM
I am facing the same issue. Pls post here, if you find the solution.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2022 08:41 AM
The script needs to return false
to cancel submission, but the part handling workspace does not return anything at all at any time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2022 05:22 AM
please advise here
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2022 01:55 AM
can you help me here please.