1

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.

2 Answers 2

6

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>
7
  • 1
    Example is good. But there all fields are displayed as input field. But I want to display all fields in PageBlockTable in Page. Feb 18, 2014 at 18:16
  • 2
    @Rudra_NoVoice The same principle still applies. Just put the loop within a pageBlockSection
    – Kevin P
    Feb 18, 2014 at 18:24
  • 1
    Again, after a quick google search, the following example shows up: salesforce.stackexchange.com/questions/245/… Feb 18, 2014 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. Feb 18, 2014 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) Feb 18, 2014 at 18:24
0

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> 

2
  • 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. Feb 26, 2016 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, 2016 at 18:23

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.