Support Article
Document download is performed only for the link clicked first
Summary
There are multiple links configured to download different documents. However, document download occurs only when the first link is clicked.
Error Messages
Not Applicable
Steps to Reproduce
- Create a section with multiple links.
- Add an action or event combo for the links: onClick, Section Refresh, and activity pyDownloadBinaryFile.
- Click a link to a download file.
- Click another link to download a different file.
Root Cause
The section refreshes on the click of the link and this causes the issue.
Resolution
Perform the following local-change:
1. Copy the following JavaScript function in the UserWorkForm.
function downloadFile(activityName, className, applicationName, fileName, fileType){
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>
2. Configure run script on download of the link and call this function.
Published April 12, 2017 - Updated July 22, 2021
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.