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
UrvikUrvik 

Display fields on Visualforce Pdf

Hi, I have a few record types in our system and each record type has different page layout. Each page has almost sames fields with small variations. I have created a visualforce page pdf for the detail page and a button on detail page, which by clicking generates pdf of the detail page. But since there is a small variation in each page layout, I don't want to create many visualforce pages. Is there a way to display fields dynamically on visualforce pdf based on the record type/page layout?
Balaji Chowdary GarapatiBalaji Chowdary Garapati
@Urvik:

 Try using Field Sets, create a fieldset for each of your record type, based on record type of id you can pick the right field set from controller of page,  and you can display them on vf page, below is reference for that:
http://www.salesforce.com/us/developer/docs/pages/Content/pages_dynamic_vf_field_sets.htm

 
UrvikUrvik
Thanks Balaji... I have been trying the following approach but not working.. Any clue?
 
<apex:page standardController="Auto__c" renderAs="pdf">

 <apex:form >
  <apex:pageBlock title="Details">
      <apex:pageblockSection columns="1" rendered="{!recordType == 'Trucks'}">
          
          <apex:repeat value="{!$ObjectType.Auto__c.FieldSets.Trucks}" var="f">
                <apex:inputfield value="{!Auto__c[f]}">
                </apex:inputfield>
          </apex:repeat>
      </apex:pageblockSection>
          
       <apex:pageblockSection columns="1" rendered="{!recordType == 'Cars'}">   
          <apex:repeat value="{!$ObjectType.Auto__c.FieldSets.Cars}" var="f">
                <apex:inputfield value="{!Auto__c[f]}">
                </apex:inputfield>
          </apex:repeat>
  
      </apex:pageblockSection>
  </apex:pageBlock>

 </apex:form>
</apex:page>