Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am having a Custom Object (Say MyCustomObj).It has fields A,B,C,D,E. I have created a Fieldset and added A,B,C fields for MyCustomObj.

By using Dynamic SOQL I got the values of all fields including fieldset and stored it in a list. That means this list has all values of A,B,C fields of MyCustomObj.

Now I want to populate those values in a Repeater in a VF Page.

How I will display?

Any help would be appreciated.

share|improve this question
up vote 5 down vote accepted

There are several examples if you google "Fieldsets in Visualforce".

Here's a nice tutorial from our own SSE guru Bob Buzzard:

http://bobbuzzard.blogspot.com/2011/02/visualforce-field-sets.html

 <apex:repeat value="{!$ObjectType.Account.FieldSets.General}" 
                    var="field">
              <apex:inputField value="{!Account[field]}" />
           </apex:repeat>
share|improve this answer
1  
Example is good. But there all fields are displayed as input field. But I want to display all fields in PageBlockTable in Page. – SFDC Geek Feb 18 '14 at 18:16
2  
@Rudra_NoVoice The same principle still applies. Just put the loop within a pageBlockSection – Kevin P Feb 18 '14 at 18:24
1  
Again, after a quick google search, the following example shows up: salesforce.stackexchange.com/questions/245/… – James Loghry Feb 18 '14 at 18:24
1  
Rudra_NoVoice the example shows how to can access it. you just need to modify the code to use different components than the Inputs. – Salesforce Wizard Feb 18 '14 at 18:24
2  
its the same concept, just different tags... and the {!Account[field]} part doesn't need to be in anything (it can be just that, with out the apex:input etc) – SalesForceGirl Feb 18 '14 at 18:24

You can find some information in spec (for example how display field label in page): https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_dynamic_vf_field_sets.htm

<apex:page standardController="Contact">
<apex:pageBlock title="Fields in Proper Names">
    <apex:pageBlockTable value="{!$ObjectType.Contact.FieldSets.properNames}" var="f">
        <apex:column value="{!f}">
            <apex:facet name="header">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:pageBlockTable> 
</apex:pageBlock> 

share|improve this answer
1  
Please answer more than an URL, at minimum include the relevant parts in your answer so that your answers remains meaningful even if the external source may go offline. – Samuel De Rycke Feb 26 at 16:47
1  
@SamuelDeRycke While this is true, it's somewhat ironic considering the accepted (and popular) answer made the same error. – Adrian Larson Feb 26 at 18:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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