I want to pass multiple id into the getParameter method so that i can display multiple record in my excel file currently the id is overidden and it is taking the last id . So how to pass multiple id into getParameter method
Here is the vf page code
<apex:page standardController="Case" contentType="application/vnd.ms-excel#AccountExcel.xls " applyHtmlTag="false" showHeader="flase">
<apex:pageBlock >
<apex:pageBlockTable value="{!Case}" var="caseList" >
<apex:column value="{!caseList.Unit_Number__c}"/>
<apex:column value="{!caseList.Unit_Type__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Below is the apex class
global class AuditRequestReportController
{
@Future(callout=true)
public static void auditReportCreate(Id id)
{
try
{
System.debug('Controller parent Id'+id);
PageReference pagePdf = new PageReference('/apex/AuditRequestReport');
System.debug('Page reference');
// pagePdf.getParameters().put('id', id);
System.debug('parameter passed to vf page');
List <Case> caseList = [SELECT CaseNumber,Id, Unit_Number__c, Unit_Type__c from Case where Audit_Request_Name__c =: id];
for(Case cs : caseList)
{
pagePdf.getParameters().put('id', cs.Id);
}
Blob pdfPageBlob;
System.debug('Test');
try{
pdfPageBlob = pagePdf.getContent();
}catch(VisualforceException e){
pdfPageBlob = Blob.valueOf('error');
}
System.debug('Test2');
ContentVersion cv = new ContentVersion();
cv.ContentLocation = 'S';
cv.PathOnClient = 'Audit Request Report.xls';
cv.Origin = 'H';
cv.Title ='Audit Request Report.xls';
cv.VersionData = pdfPageBlob;
insert cv;
System.debug('Test3');
ContentVersion content = [select ContentDocumentId from ContentVersion where Id =: cv.Id];
ContentDocumentLink cl = new ContentDocumentLink(LinkedEntityId = id, ContentDocumentId = content.ContentDocumentId, ShareType = 'I');
System.debug('Test4' );
insert cl;
}
catch(Exception e)
{
System.debug('Exception -'+e);
}
}
}
below is the trigger which is calling apex class method and passing parent record id
trigger AuditCompletedReport on Audit_Project__c (before update) {
Audit_Project__c auditRefrence = Trigger.New[0];
if(auditRefrence.Status__c == 'Completed')
{
System.debug('Status Completed');
if( Trigger.oldMap.get( auditRefrence.Id ).Status__c != Trigger.newMap.get( auditRefrence.Id ).Status__c )
{
if(HelperClass.firstRun){
AuditRequestReportController.auditReportCreate(auditRefrence.Id);
System.debug('audit Reference id = '+auditRefrence.Id);
HelperClass.firstRun = false;
}
}
}
}
showHeader="flase"
should befalse
. Not sure if that's causing issues or not