Create a Glide Window on an onSubmit Client Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2022 08:33 PM
Hi,
I am working on a glide window on an onSubmit Client script. The reason I chose this is because if several fields are updated by a certain group of users then I want a popup window that forces them to add a work notes. I didn't want to create an onChange for each of the fields.
I am testing the concept using the Change Confirmation Reason, I will eventually create my own UI page, but I am just using this to Test.
Here is the script that I have:
function onSubmit() {
var shortDesc = g_form.getControl('short_description');
var longDesc = g_form.getControl('description');
var workNotesComplete = false;
if (shortDesc.changed || longDesc.changed) {
var dialog = new GlideModal('change_confirm_reason', false, 648, 250);
dialog.setTitle(new GwtMessage().getMessage('Cancel Change Request'));
dialog.setPreference('focusTrap', true);
dialog.setPreference('onPromptComplete', onPromptComplete);
dialog.setPreference('onPromptCancel', onPromptCancel);
dialog.on('closeconfirm', onPromptCancel);
dialog.setPreference('buttonLabelComplete', new GwtMessage().getMessage('OK'));
dialog.setPreference('buttonLabelCancel', new GwtMessage().getMessage('Cancel'));
dialog.render();
return false;
}
function onPromptComplete(notes) {
workNotesComplete = true;
g_form.setValue("work_notes", notes);
gsftSubmit(null, g_form.getFormElement(), 'sysverb_update_and_stay');
}
function onPromptCancel() {
if (workNotesComplete)
return;
}
}
The issue that I am having is the popup window displays and when I add a note and hit submit, it doesn't save instead it opens another popup window. It's like it is in a loop.
Any ideas on how I can fix this?
- Labels:
-
Script Debugger
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2022 10:28 PM
Hi,
try this
function onSubmit() {
var shortDesc = g_form.getControl('short_description');
var longDesc = g_form.getControl('description');
var workNotesComplete = false;
if (shortDesc.changed || longDesc.changed) {
var dialog = new GlideModal('change_confirm_reason', false, 648, 250);
dialog.setTitle(new GwtMessage().getMessage('Cancel Change Request'));
dialog.setPreference('focusTrap', true);
dialog.setPreference('onPromptComplete', onPromptComplete);
dialog.setPreference('onPromptCancel', onPromptCancel);
dialog.on('closeconfirm', onPromptCancel);
dialog.setPreference('buttonLabelComplete', new GwtMessage().getMessage('OK'));
dialog.setPreference('buttonLabelCancel', new GwtMessage().getMessage('Cancel'));
dialog.render();
return false;
}
function onPromptComplete(notes) {
workNotesComplete = true;
g_form.setValue("work_notes", notes);
g_form.save();
}
function onPromptCancel() {
if (workNotesComplete)
return;
}
}
regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2023 10:05 AM
Hi Ankur,
I am facing the same problem. Unfortunately your script doesn't fix the infinite loop.
Regards, Darek