Using FieldSets in Visualforce

What is FieldSet?, A field set is a grouping of fields, for example UserInfo is a field Set where it contains basic details like User firstName, lastName, email, title, mobile, these can be grouped under a FieldSet

Visualforce Page

<apex:page standardController="Account">
    <!-- To Display field Values Only -->
    <apex:repeat value="{!$ObjectType.Account.FieldSets.thephani__Account_Information}" var="f"> 
        <apex:outputText value="{!Account[f]}" /><br/>
    </apex:repeat>
    
    <!-- To Displya field Name, field Label, field datatype & field Value-->
    <apex:pageBlock title="Fields in Proper Names">
        <apex:pageBlockTable value="{!$ObjectType.Account.FieldSets.thephani__Account_Information}" var="f">
            <apex:column value="{!f}">
                <apex:facet name="header">API Name</apex:facet>
            </apex:column> 
            <apex:column value="{!f.Label}">
                <apex:facet name="header">Label</apex:facet>
            </apex:column> 
            <apex:column value="{!f.Type}" >
                <apex:facet name="header">Data Type</apex:facet>
            </apex:column> 
            <apex:column value="{!Account[f]}" headerValue="Field Value  bnb  " />
       </apex:pageBlockTable> 
    </apex:pageBlock> 
</apex:page>

Output

Subscribe to Phanindra Mangipudi

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe