Support Article
Screen is loading after the file downloads
Summary
After downloading the file, browser is throwing 'pega' is undefined java script error.
Error Messages
Message: 'pega' is undefined
Line: 1
Char: 6236
Code: 0
URI: http://hotname/prweb/PRServlet/mUevMtvcJErF3ChTkHbdGuhP7adKLV4F*/webwb/pzpega_ui_grid_1512520753.js!pzpega_ui_grid_dragdrop_13859374587.js!pega_yui_resize_1400790147.js!!.js
Steps to Reproduce
Configure a button to download an excel file and refresh this screen.
Root Cause
A software use or operation error : downloading a file in Ajax request(refresh section) is not supported. This will cause many issues, as it disrupts Ajax.
Resolution
Perform the following local-change:
1. Paste the below script in UserWorkForm
<script>
getFileToClient = function() {
var strUrlSF = new SafeURL("@baseclass.ExportToExcel"); //replace with necessary activity and pass appropriate params
var strUrl = pega.u.d.url +"&"+ strUrlSF.toQueryString();
var ifrm = document.getElementById("fileDownloadIframe");
if(ifrm==null){
ifrm = document.createElement("iframe");
ifrm.setAttribute("id", "fileDownloadIframe");
}
ifrm.setAttribute("src", strUrl);
ifrm.setAttribute("height","0px");
ifrm.setAttribute("width","0px");
document.body.appendChild(ifrm);
};
</script>
2. Configure Run Script on the export to excel button to call the above method, that is getFileToClient.
Published February 15, 2016 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.