- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2025 12:02 AM - edited 07-30-2025 12:06 AM
Hi Ankur, Kindly help me with this code. My requirement is to have Yes/No buttons. Upon No response, it has to open external URL. I have made changes in your code as below. Though it is working fine for me I just wanted to check with you whether it has any performance impact. Thought it is opening url in new tab but the dialog box remains in the page. how to disappear dialog box when I click on NO?
Below is my OnChange client script

When I click NO the above dialog box should disappear like how it disappears if we click on Yes.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2025 12:31 AM
I believe since we are using the OOTB glide_modal_confirm, we can't change the position.
try this updated code and anyhow you need to close modal if it's Yes/No
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var dialog = new GlideModal('glide_modal_confirm', true, 300);
dialog.setTitle('Apps Assist Check Point');
dialog.setPreference('body', 'Did you check Apps Assist?');
dialog.setPreference('focusTrap', true);
dialog.setPreference('onPromptCancel', doCancel);
dialog.setPreference('onPromptComplete', doComplete);
dialog.render();
function doComplete() {
// YES button clicked
dialog.destroy();
// Your logic for Yes goes here.
}
function doCancel() {
// NO button clicked
dialog.destroy();
top.window.open("https://mywebsite.com/", "_blank");
g_form.setValue('state', oldValue);
}
}
it worked for me, Output below
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2025 01:43 AM
is the URL getting opened in new tab?
There is some issue going on in community that images are not visible.
please add it using browse feature and add as attachment to post
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2025 01:52 AM - edited 07-30-2025 01:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2025 02:05 AM
I don't see any error related to modal.
What if you don't set the field using g_form?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2025 02:15 AM
If dialog box disappears, then users will save the form with new state that I don't want them to do so.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2025 02:18 AM
then save the form after setting and then reload
move the destroy line at the end
function doCancel() {
// NO button clicked
top.window.open("https://mywebsite.com/", "_blank");
g_form.setValue('state', oldValue);
g_form.save();
dialog.destroy();
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader