function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jeff Bryant 16Jeff Bryant 16 

How to pass page reference from Lightning Component to Visualforce page

I have a lightning component that is a confirmation modal that will try to call a VF Page that will export information about a batch via a CSV file. The CSV Export VF Page when called will automatically export and download a CSV file with the batch information. I'm trying to redirect to this page from a Lightning Component but failing (the export information is null). The "Continue" code is my attempt to reference the VF Page. I'm assuming I'll have to pass the batch information or page reference when I call the VF Page? Any help is greatly appreciated!
<aura:component controller="ExportToCSVBatchPopup" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    
    <aura:attribute name="loanCount" type="integer"/>
    <aura:attribute name="batchName" type="string"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
    <p>Exporting Batch Information.
    </p>
    <br/>
    <footer >
        <div class="slds-align_absolute-center">
            <lightning:button variant="brand" 
                              label="Continue"
                              title="Continue"
                              onclick="{! c.Continue }"/>
        </div>
    </footer>
</aura:component>




({
   doInit: function(component, event, helper) {
      helper.GetCount(component, event, helper);
      helper.GetName(component, event, helper);
   },
 
   Continue: function(component, event, helper) {
       var urlEvent = $A.get("e.force:navigateToURL");
       urlEvent.setParams({
           "url":"/apex/ExporttoCSVBatch",
           "isredirect": "true"
       });
       urlEvent.fire();
   },
})

 
Best Answer chosen by Jeff Bryant 16
ShivankurShivankur (Salesforce Developers) 
Hi Jeff,

Yes, thats correct, your VF page might be expecting for a record Id or batch Id to get the required information and export the details.

You might want to modify the redirection URL like below:
  var url = '/apex/ExporttoCSVBatch?id=' + recordId;
Hope above information helps, Please mark as Best Answer so that it can help others in the future.

Thanks.