Support Article

Custom export to Excel button only works once

SA-35468

Summary



A custom export to Excel button only works once.

Note: This button is not the Out-of-the-box (OOTB) export to Excel feature seen in reports.

It is a pxButton configured to refresh the current section, and call a custom activity which eventually calls OOTB @baseclass.ExportToExcel.

In this scenario it is being used to export grid data to Excel.

 


Error Messages



Not Applicable


Steps to Reproduce

  1. Click on this custom configured button to generate Excel
  2. Button does not work anymore until you reload the screen


Root Cause



This design cannot use refresh section to download the Excel file.

Resolution



Perform the following local-change:

1) Define this custom function in UserWorkform:



<script> 
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) Change button to call this custom function.

Note: The params such as filename and type params do not necessarily matter here depend on implemented custom activity. 



Then custom export activity itself stays the same, no changes are needed there unless to use these new params.



 

 

Suggest Edit

Published October 8, 2020


50% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.