I had a VF Page on a Detail Page Button created on a custom object.

On button click, the vf page is downloaded as pdf file as expected.

In lightning experince, after the file is downloaded, the UI is not staying on the detail record page. It works fine in classic experince.

One of the solution I tried below,

<apex:page standardController="customobject" extensions="customController" showHeader="false"
           cache="true"  >
<apex:form id="form" >
 .. add pdf content here.
<apex:actionFunction name="redirect" action="{!redirectToRec}"/>

I called the script at the end to have redirect after the pdf attachment is formed. I dont see the apex method being called with the above approach.

Please let me know if there are any other approaches.

  • You cannot run JavaScript in a PDF-rendered Visualforce page. – David Reed Jun 2 '20 at 18:14
  • Any other way I could try the redirect to record page or staying on detail page in lightning experince? – Anurag Jun 2 '20 at 18:18

You can choose the behavior to "Display in new Window" on Custom Button. May be that will work in Lightning and open in new tab/Download the file and close the tab as soon you click it.

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.