Using GlideModal to alert for assignment group change
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2020 10:35 AM
Hi all,
I have a requirement to display a custom alert when the Assignment group is changed to a particular group. We'd like to use GlideModal instead of the standard Javascript alerts to have more flexibility, but it's been a little challenging to finalize what should be simple...
- Created UI page with detailed warning, and OK/Cancel buttons
- Created client script for onChange on assignment group field
- Script calls GlideModal to display UI page
- If user clicks OK -> GlideModal window disappears and new assignment group remains on form
- If user clicks Cancel -> GlideModal window disappears and original assignment group is restored to form
However, the current code is keeping the new assignment group even when the user clicks Cancel. i.e., it's not being restored to the original assignment group value. Not sure if this is because I'm not passing the right info to my client script, or if I need to be using GlideAjax instead?
Here's the client script running onChange on the Assignment group field:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (newValue === 'df5d0122dbb04410ed3f27360596191c') {
var dialog = new GlideModal('sn_hr_core_tier3alert');
dialog.setTitle("Alert: Confirm assignment group change");
dialog.setPreference('focusTrap', true);
dialog.setPreference('cancel_button', doCancel);
dialog.render();
}
function doCancel() {
g_form.setValue('assignment_group', oldValue);
}
}
Here's my UI page code:
HTML
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<p><strong>This assignment group (Tier 3) is not to be used for escalations.</strong></p>
<p>Select OK to confirm the change, or Cancel to keep the original assignment group.</p>
<g:ui_form>
<div class="modal-footer">
<span class="pull-right">
<button class="btn btn-default" id="cancel_button" onclick="window.GlideModalForm.prototype.locate(this).destroy(); doCancel(); return true" style="min-width: 5em;" title="" type="submit">
Cancel
</button>
<button class="btn btn-primary" id="ok_button" onclick="window.GlideModalForm.prototype.locate(this).destroy(); return false" style="min-width: 5em;" title="" type="submit">
OK
</button>
</span>
</div>
</g:ui_form>
</j:jelly>
Client script [this code seems duplicative; also not sure if g_form is even available via the UI page?]
function doCancel() {
g_form.setValue('assignment_group', oldValue);
}
Processing script [this code seems duplicative; also not sure if g_form is even available via the UI page?]
g_form.setValue('assignment_group', oldValue);
Any info would be much appreciated. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2020 11:49 AM
Hi Zach,
try with :
function doCancel() {
GlideDialogWindow.get().destroy();
return false;
}
Cheers,
Joro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2020 09:54 AM
Hi Joro,
Thanks for the fast reply. Unfortunately, that was one of the solutions we tried but it doesn't restore the original assignment group value.