UI Page not closing in agent workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2023 11:02 AM
Hi All,
I have configured a UI Page in Agent Workspace, but the pop-up doesn't close automatically when clicking on "OK" , after clicking OK it is opening the URL I wanted.
Client script:
function closeModal() {
GlideDialogWindow.get().destroy();
return false;
}
function openUrl(url) {
this.open(url, "_blank");
}
function saveValues(mthis) {
var butn = gel('ok_button').disabled = true;
var table = '${JS:sysparm_sys_table_name}';
var s = [];
var emv = emailvals.querySelectorAll('input[type="checkbox"]');
var sysID = '${JS:sysparm_sys_source_id}';
[].forEach.call(emv, function(e) {
if (e.checked)
s.push(e.name);
});
var url = "/my_url"
var gajax = new GlideAjax('global.script_include');
gajax.addParam('sysparm_name', 'function');
gajax.addParam('sysparm_ids', s.join(','));
gajax.getXML(function(r) {
openUrl(url);
});
return true;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2023 10:19 PM
Hi @Palak Midha ,
It looks like the issue is with the saveValues function. In this function, you are calling the openUrl function after the AJAX call completes successfully, which is opening the URL in a new tab. However, you are not calling the closeModal function to close the pop-up.
To fix the issue, you need to modify the saveValues function to first call the closeModal function before calling the openUrl function.
Here's how you can modify the saveValues function:
function saveValues(mthis) {
var butn = gel('ok_button').disabled = true;
var table = '${JS:sysparm_sys_table_name}';
var s = [];
var emv = emailvals.querySelectorAll('input[type="checkbox"]');
var sysID = '${JS:sysparm_sys_source_id}';
[].forEach.call(emv, function(e) {
if (e.checked)
s.push(e.name);
});
var url = "/my_url"
var gajax = new GlideAjax('global.script_include');
gajax.addParam('sysparm_name', 'function');
gajax.addParam('sysparm_ids', s.join(','));
gajax.getXML(function(r) {
closeModal(); // Call closeModal function before opening the URL
openUrl(url);
});
return true;
}
If my response helps you to resolve the issue close the question by ✅Accepting solution and hit 👍thumb icon. From Correct answers others will get benefited in future.
Thanks,
Ratnakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2023 02:52 AM
Hi Ratnakar,
I tried, but the popup doesn't close and also the URL is not opening if I do this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2023 06:56 AM
I found the solution... started to use window.open and then refreshed the page, that worked like a charm for me