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
Leo CLeo C 

Trouble displaying select records on PDF (and download)

I have a list button for the Product2 object in my org that redirects to a VisualForce page. This VisualForce page displays the product name and description of all the product records that were selected in list view. That works fine, and I have the page rendered as a PDF using the renderAs tag.
renderAs="pdf"
My problem occurs when I go to download the PDF using the provided button in the browser. When I do this, the PDF is downloaded but the content shows the name and description of every single product record, not just the ones I selected.
How can I get the downloaded PDF to show only the selected records?
Am I missing something? I feel like this may be some sort of caching issue but I really don't know honestly.

Here is my VF code for reference:
<apex:page standardController="Product2" recordSetVar="prods" showHeader="false" extensions="CatalogueGenerationExt" renderAs="pdf">
    <!-- Static resource style sheet -->
    <apex:stylesheet value="{!URLFOR($Resource.cataloguegenstyle)}"/>

    <div class="main-containter" style="background-image:url('{!URLFOR($Resource.watermarkfull)}');">
        <div class="head">
            <div class="genTitle">
                Custom Catalog Generation (<apex:outputText value="{0, date,MMMM d',' yyyy - HH:mm 'GMT'}"><apex:param value="{!NOW()}"/></apex:outputText>)
            </div>
        </div>
        <div>
            <apex:repeat value="{!prods}" var="q">
                <div class="product-inner">
                    <div class="prod-title">
                        <h3>
                            <apex:outputField value="{!q.Name}"/>
                        </h3>
                    </div>
                    <div class="client-desc-cont">
                        <apex:outputField value="{!q.Client_Description__c}"/>
                        <apex:outputText rendered="{!q.Client_Description__c=Null}">&lt;No Description available&gt;</apex:outputText>
                    </div>
                </div>
            </apex:repeat>
        </div>
    </div>
</apex:page>

 
SUCHARITA MONDALSUCHARITA MONDAL
Hi Leo C,

I guess in your extension class 'CatalogueGenerationExt' you are fetching all the records. Try fetching only the record which you are currently selecting. You can do this by passing the Current Record Id in your SOQL.

I think then it should work.

Share your thoughts!

Thanks,
Sucharita