GlideOverlay window is not closing on click of Submit button.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2017 08:59 AM
Hello,
We have a calculate risk UI action which opens the an overlay window using Glide Overlay. When user completes the assessment and clicks on the Submit button, the overlay window stays as it is and it shows the Parent change ticket in the overlay window.
function invokeAssessment() {
g_form.hideAllFieldMsgs();
var isSubmitted = false;
var id = g_form.getUniqueValue();
var ga = new GlideAjax("CreateAssessment");
ga.addParam("sysparm_name", "checkAssessment");
ga.addParam("sysparm_id", id);
ga.addParam("sysparm_class", "change_request");
ga.getXMLAnswer(function(res) {
if (res == "No Condition")
g_form.addInfoMessage(getMessage("There are no risk assessments defined for this request"));
else {
var resArr = [];
resArr = res.split(",", 2);
var taskAsmtID = resArr[0];
var assessmentName = resArr[1];
var url = "survey_take.do?sysparm_survey=" + encodeURIComponent(assessmentName);
url += "&sysparm_task_assessment=" + taskAsmtID;
url += "&sysparm_survey_update=false";
url += "&sysparm_return_url=" + encodeURIComponent("/chg_risk_close_assessment_dialog.do?sysparm_stack=no");
url += "&sysparm_stack=no";
var d = new GlideOverlay({
title: getMessage("Risk Assessment"),
iframe: url,
width: "60%",
height: "80%",
onBeforeClose: function() {
if (isSubmitted){
return true;
}
var ga = new GlideAjax("CreateAssessment");
ga.addParam("sysparm_name", "deleteAssessment");
ga.addParam("sysparm_id", taskAsmtID);
ga.getXMLAnswer(function(res){});
},
onAfterLoad: function() {
d.autoDimension();
d.autoPosition();
d._createIframeShim();
var iframe = d.getIFrameElement();
var post_button = iframe.contentWindow.document.getElementById("post_survey");
if (post_button.addEventListener) {
post_button.addEventListener("click", function(eventObj) {
if (eventObj.view.mandatoryResult) {
isSubmitted = true;
}
});
} else {
post_button.attachEvent("onclick", function(eventObj) {
if (iframe.contentWindow.mandatoryResult) {
isSubmitted = true;
}
});
}
}
});
d.render();
window.g_parentDialog = d; // Accessed from chg_risk_close_assessment_dialog UI page
}
});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2017 03:34 PM
In your onAfterLoad within any of the cases where you set isSubmitted = true, try to close the overlay there. For instance:
...
if (post_button.addEventListener) {
post_button.addEventListener("click", function(eventObj) {
if (eventObj.view.mandatoryResult) {
isSubmitted = true;
window.g_parentDialog.close(); //add this line to your script
}
});
} else {
post_button.attachEvent("onclick", function(eventObj) {
if (iframe.contentWindow.mandatoryResult) {
isSubmitted = true;
window.g_parentDialog.close(); //add this line to your script
}
});
}
...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2017 08:27 PM
Try
window.parent.GlideOverlay.close(<id of your GlideOverlay dialog>)
Regards,
Durgesh