MSOGenerateExcelFile is not working in second click

My Requirement is to Exporting an Excel sheet for that i have created a button and used actions are Refresh Section and mentioned an Custom Activity from that calling MSOGenerateExcelFile . Initially means on first click it’s working fine but from second click it’s not working in 8.5.4 but it’s working fine 7.1.5 .

Can any one help me to Achieve this Scenario.

Thanks,

Srinivas

@SrinivasaR8416 could you clarify - you are using one single button, and are requesting the user clicks it multiple times in a row?

Could you check to see if you could work around the issue by using the suggestions in this post?

There are also some support article which might help - see here and here.

Note also: on first click the current harness will open url in window and when it fires the activity MSOGenerateExcelFile after executing it it sends out the ajax response to the UI (DOM / Browser) .This content on harness refresh is been changed and the content which is been received by UI is not been recognized that is why the operation is not working for second time. The Second time when you click on the button, it expects the new session to download the file.

When we implement open url in window, this action accepts all types of content and execute it properly irrespective of the content. Due to which it is working fine.

In 7.x versions the content type strict mode is not been there and also templatized UI feature is also not present. But in 8.x version UI is templatized and the data rendering on to the UI has been changed( server sending xml data and in client side adding html tags and then rendering in UI) . Due to which it is working fine in 7.x and not working in 8.x.

As per Pega for downloading any file the ideal approach to use is "open url "in window action.

Try the following Solution :
perform the below local change in order to download the file multiple time on click of a button or link

  1. Add the below code in the userwork form
<script>

function downloadFile(pyActivity)

{

var SURL = SafeURL_createFromURL(pega.u.d.url);

SURL.put('pyActivity',pyActivity);

var formEle = document.createElement('form');

formEle.id = "download -file";

formEle.method = "POST";

formEle.action = SURL.toURL();

if(pega.env.ua.webkit)

{

formEle.target = "";

}

document.body.appendChild(formEle);

formEle.submit();

document.body.removeChild(formEle);

}

</script>
  1. In the link/button where you click in order to download the excel add the below

OnChange -->Runscript add the Function name " downloadFile"

In the parameters pyActitvity–>“Test”(Custom Activity which calls the pxGenerateExcelFile).

Please follow the steps outlined in the following support article. and here.

@MarijeSchillern Hi Marije,

Thank you so much now it’s working fine when i use open URL In New Window and i used window name as _self so the file was downloaded in same window.

@ coming to the clarification from my end it was a single button and asking user to click it for multiple times.

Thanks

Srinivas

@SrinivasaR8416 can you click ‘Accept Solution’ and confirm your issue has been resolved through one of the articles suggested?