Need a way to close g_modal.showFrame based on API results
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
This is my requirement.
There is a UI Action on HR Agent Workspace. When clicked, it invokes a UI Page (which has CSS/HTML for a custom loader) as a popup using g_modal.showFrame. The UI Action proceeds to do a GlideAjax and calls an API and gets the result. If API is successful, then the modal must be destroyed and form has to reload. If unsuccessful, the modal must be destroyed and an error message should be displayed.
Need help on below 2 points:
1. Close the modal automatically
2. Remove the white background in the modal.
Below is the code snippet:
UI Action Workspace script:
function agentAssist() {
var caseSysId = g_form.getUniqueValue();
var ui_page_id = <sys_id of UI Page>;
g_modal.showFrame({
url: '/ui_page.do?sys_id=' + ui_page_id + '&caseid=' + caseSysId,
size: 'sm',
autoCloseOn: 'EMPTY_BODY', //Tried URL_CHANGED as well. No luck
showClose: false
});
var ga = new GlideAjax('<SI>');
ga.addParam('sysparm_name', '<function>');
ga.addParam('sysparm_sys_id', caseSysId);
ga.getXML(function(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == 'Success') {
location.reload();
//window.top.g_modal.destroy();
} else {
//window.top.g_modal.destroy();
g_form.addErrorMessage('API failed. Please contact Administrator');
}
});
}
Labels:
- Labels:
-
Human Resources Service Delivery
0 REPLIES 0
