I have a commandbutton at my page which open a new window. The url should be different for each item in the list, but if I put the url with the condition into the onclick the url doesnt work.

With flexible Condition:

<apex:commandButton action="{!Stats_In}" onclick="window.open('/servlet/servlet.FileDownload?file={!MSL.Id}')" value="Download" reRender="Dummy">

It open a new window but doesn't work https://OUR_DOMAIN.cs87.my.salesforce.com/servlet/servlet.FileDownload?file=a068E0000045JaOQAU

Hard coded file:

<apex:commandButton action="{!Stats_In}" onclick="window.open('/servlet/servlet.FileDownload?file=00P8E000004Ygm4UAC')" value="Download" reRender="Dummy"> 

It open an new window and works fine. https://OUR_DOMAIN.cs87.content.force.com/servlet/servlet.FileDownload?file=00P8E000004Ygm4UAC

If you can see, the url is a bit different, not working my.salesforce.com --> working content.force.com. How is that possible? Can I fix that problem?


"aXX" Id values are custom objects, while "00P" Id values are Attachment records. You will need to get the correct Id value in order to use servlet.FileDownload.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.