You need to sign in to do that
Don't have an account?
Shubham Bansal 45
I want to pass record id to vf page on button click of lightning component.
Explaination:
I have a lightning component on record page and on that component i have a generate pdf button on the button click i have to pass record id to vf page and generate pdf.
i have created my vf page. but i am not able to pass record id and and show that vf page .
Any help is appreciated .Its urgent.
May I know how are you going to display the pdf once it is generated on button click?
Navigation would be like this:
i have to display my pdf on the new tab of the browser .
My vf page is code is working fine the only problem is the id i want.
My js code:
exportPdf: function(component, event, helper) {
var recordId = component.get("v.recordId");
console.log('Recardid',recordId);
let urlVar = 'https://project--acc.cs18.visual.force.com/apex/demoPdf?core.apexpages.request.devconsole=1'+'/?&rId='+recordId;
console.log('urlVar',urlVar);
var eUrl= $A.get("e.force:navigateToURL");
eUrl.setParams({
"url": urlVar
});
eUrl.fire();
}
My apex code:
public List<ParentWrap> parentWrapperList {get;set;}
public PP4_PartnerBusinessPlan(ApexPages.StandardController controller){
String recordId = ApexPages.currentPage().getParameters().get('rId');
Partner_Business_Plan__c abc =(Partner_Business_Plan__c) controller.getRecord();
system.debug('abc'+abc);
system.debug('shdsd'+recordId);
And so on...
I have doing everything like you say already but system.debug('shdsd'+recordId); gives null
Plz update your navigate Url as below :
Have you any idea how to change the name of pdf opened in new name according to the record name.
I try by using this: Apexpages.currentPage().getHeaders().put('content-disposition', 'attachment; filename='+pp.Name+'.pdf');
but it downloads pdf instead of showing it in new tab.
public PDMS_CRED_PDFGenerator(ApexPages.StandardController controller) {
currentRecordId = ApexPages.CurrentPage().getparameters().get('id');
system.debug('currentRecordId///'+currentRecordId);
}
instead of:
public PDMS_CRED_PDFGenerator() {
currentRecordId = ApexPages.CurrentPage().getparameters().get('id');
system.debug('currentRecordId///'+currentRecordId);
}
for your scenario you cannot use 'ApexPages.StandardController controller' as a parameter for constructor, it should not receive any parameter actually, so in short the 2nd way will work.
Thanks,
Namrata