I have seen examples where people display fieldset for an sobject.

But instead of mySobject if i want to display the field set for a list of sobjects?

  • for example: <apex:page standardController="Contact"> <apex:repeat value="{!$ObjectType.Contact.FieldSets.properNames}" var="f"> <apex:outputText value="{!Contact[f]}" /><br/> </apex:repeat> </apex:page> – Sanjay Paryani Oct 4 '16 at 2:56
  • Is it a list of SObjects of the same type or of different SObject types? – Lance Shi Oct 4 '16 at 3:13

I suppose you mean by a list of SObjects of the same SObject type, say Contact. And then the code can be pretty easy.


<apex:page standardController="Contact" extensions="fieldSetExtension"> 
    <apex:repeat value="{!contactList}" var="c">
        <apex:repeat value="{!$ObjectType.Contact.FieldSets.Name_Set}" var="f"> 
            <apex:outputText value="{!c[f]}" />


public class fieldSetExtension 
    public List<Contact> contactList {get; set;}
    public fieldSetExtension(ApexPages.StandardController stdController)
        contactList = [Select Id, Name, LastName, Email, MobilePhone, Level__c From Contact];

Of course, you should be using Dynamic SOQL here, which I am too lazy to implement here. But the concept is the same.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.