Support Article
Unable to download the Excel file on click of a button
Summary
Unable to download the Excel file on click of a button.
Error Messages
Not Applicable.
Steps to Reproduce
- Create an activity
- Call the MSOGenerateExcelFile activity in the Run Activity action set of a button
- Click the button on the portal to export the Excel file
Root Cause
A defect in Pegasystems’ code or rules.
Resolution
Perform the following local-change:- Copy the below JavaScript in the UserWorkForm HTML fragment and save it in the application ruleset:
<script>
function downloadFile(activityName, className, applicationName, fileName, fileType){
debugger;
var suURL = SafeURL_createFromURL(pega.u.d.url);
suURL.put("pyActivity", activityName);
suURL.put("pyClassName", className);
suURL.put('ApplicationName', applicationName);
suURL.put('FileName', fileName);
suURL.put('FileType', fileType);var formEle = document.createElement('form');
formEle.id = "download_file";
formEle.method = "POST";
formEle.action = suURL.toURL();
if(pega.env.ua.webkit)
formEle.target = "";
document.body.appendChild(formEle);
formEle.submit();
document.body.removeChild(formEle);
}
</script> - Navigate to the Export button's Action Tab
- Remove the Run Activity action configured for the export activity
- Configure the Run Script action and call the downloadFile function
- Add the activityName, className, applicationName, fileName, fileType and pass respective values parameters
- Check the two options available under security tab's Restrict access of the activity
Published August 15, 2019 - Updated December 2, 2021
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.