Its not populating the correct Record of Product of Interest on VF page . I am calling it from screen flow in which i am updating the field of product of Interest record and after that i want to show that as a pdf on lead ,the problem is its showing on the flow that its getting the right record Id but when we open the document its not the correct record its randomly picking up the record i guess , and also here recordId = ApexPages.currentPage().getParameters().get('id'); System.debug('recordId >> '+recordId); I am not getting the Id but if i dubug the URL in that i am getting Lead Id
global class pdfGeneratorForLead {
global Id recordId {get;set;}
global Product_of_Interest__c prodCon{get;set;}
private ApexPages.StandardController stdController;
global pdfGeneratorForLead(ApexPages.StandardController stdController){
this.stdController = stdController;
recordId = ApexPages.currentPage().getParameters().get('id');
System.debug('recordId >> '+recordId);
/*----- SELECT POI FROM THE LEAD --------------- */
List<Product_of_Interest__c> poi = new List<Product_of_Interest__c>();
Set<Id> CleanCheck = new Set<Id>();
Set<Id> RustPreventive = new Set<Id>();
poi = [SELECT ID, Product_Category__c FROM Product_of_Interest__c WHERE Lead__c =: recordId];
System.debug('poi >> '+poi);
for(Product_of_Interest__c P : poi){
if(P.Product_Category__c == 'CleanCheck'){
CleanWaterBase.add(P.Id);
System.debug('CleanCheck >> '+CleanCheck);
}
else if(P.Product_Category__c == 'RUST PREVENTIVE'){
RustPreventive.add(P.Id);
System.debug('RustPreventive >> '+RustPreventive);
}
}
//----- SELECT POI FROM THE LEAD ---------------
prodCon = [SELECT Account__c,Achieved_Millipore_Value_Solids_in_mg__c,Washing_time_in_Minutes_Seconds__c,Weight_of_Job_in_Kg__c FROM Product_of_Interest__c WHERE Id =: CleanCheckLIMIT 1];
System.debug('ProdCon >>>>> '+ prodCon);
}
/*public static List<Account> pdfGeneratorForLead3() {
List<Account> ch = [SELECT id FROM Account LIMIT 2];
return ch;
}
}*/
@InvocableMethod
Global static void pdfGeneratorForLead2(List<Id> prodId) {
// List<Product_of_Interest__c> prod = new List<Product_of_Interest__c>();
System.debug('prodId >>>>>>>>> '+prodId);
Product_of_Interest__c prod = [SELECT Account__c,Achieved_Millipore_Value_Solids_in_mg__c,Achieved_Millipore_Value_Soluble_in_mg__c,
Anti_Rust_Property__c,Basic_Rate_ltr__c,Business_Volume__c,Concentration_Recommended__c,Contact__c,
Contamination_on_the_job_Oil_Dust_Typ__c,
Id,Input_Millipore_Value_Solids_in_mg__c,Input_Millipore_Value_Soluble_in_mg__c,IsDeleted,Issue_If_any__c,Job_Name__c,
Job_washed_per_day_in_Nos__c,Washing_time_in_Minutes_Seconds__c,Weight_of_Job_in_Kg__c FROM Product_of_Interest__c WHERE Id = :prodId];
System.debug('prod >>>>>>>>> '+prod);
Id leadId = [SELECT ID FROM LEAD WHERE ID =: prod.Lead__c].Id;
// Create a new PDF document
PageReference pdf = Page.pdfCreator;
pdf.getParameters().put('leadId', leadId);
Blob pdfBlob = pdf.getContentAsPDF();
// Create a new Attachment record and attach the PDF to the Opportunity
Attachment attachment = new Attachment();
attachment.Name = 'Recommendation form.pdf';
attachment.ParentId = leadId;
attachment.Body = pdfBlob;
insert attachment;
//call a future
// return prod;
}
}
This Is the controller
and this is the vf page
<apex:page standardController="Lead" extensions="pdfGeneratorForLead">
<apex:pageBlock >
<apex:pageBlockTable value="{!prodCon}" var="a">
<apex:column value="{!a.Customer_Name__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
<b>Quote Type :</b> {!prodCon.Customer_Name__c}<br/>
<apex:outputText value="{!prodCon}"></apex:outputText>
</apex:page>