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}"/>

Below is the apex class

global class AuditRequestReportController 

    public static void auditReportCreate(Id id)
        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;


            pdfPageBlob = pagePdf.getContent();

        }catch(VisualforceException e){
            pdfPageBlob = Blob.valueOf('error');
        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; 
        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 )


             System.debug('audit Reference id = '+auditRefrence.Id);
                HelperClass.firstRun = false;


  • Note that there's a typo - showHeader="flase" should be false. Not sure if that's causing issues or not Jan 6, 2020 at 18:19

2 Answers 2


Instead of using a for loop and using pagePdf.getParameters().put('id', cs.Id); to overwrite the id parameter everytime, try building a set of Ids and then add them all together at once, comma separated:

Set<Id> caseIds = new Set<Id>();

for (Case curCase : caseList) {

pagePdf.getParameters().put('ids', String.join(new List<Id>(caseIds),','));

Note that String.join() only works on List type, and using Set will ensure that you only have unique Ids and no duplicates.


Integer count = 1;

        for(Case cs : caseList)
            pagePdf.getParameters().put('id'+count , cs.Id);
            count ++;
            System.debug('Count'+count );
            System.debug('Id ='+cs.Id);

I am using above code still not getting the output

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .