Feb 26, 2011

Using Field Set on Visual Force Page

This is about how we can use Field Set. We can dynamically bind fields on our visual force page using Field Set. It is very useful when we are working with managed package.

A field set is a grouping of fields. For example we can have a field set that contains fields "Name , Email , Phone , Mobile". If the page is added to a managed package, administrator can add, remove, or reorder fields in a field set to modify the fields presented on visual force page without modifying any code. Creating a field set : Go to Setup > App Setup > Create > Objects > Select your object > Field Set (Beta) > New : 



Fields in "In the Field Set" section is displayed on visual force page and administrator can add more fields in "In the Field Set" from "Available for the Field Set" section.

Visual Force Page Code :



    
        
            
                
            
        
    



Now it will show three fields (Name, Email, Mobile) on visual force page, if we add "Phone" field from "Available for the Field Set" section to "In the Field Set" section then four fields (Name, Email, Mobile, Phone) will be displayed on visual force without changing the code.


Thanks

15 comments:

  1. Yes Ankit, This is really a good feature.
    It is also useful when drawing a custom related list. With the field set we can have the related list dynamic also.
    It also can be used to draw the labels of the field set elements when needed.

    http://simplyforce.blogspot.com/

    ReplyDelete
  2. Yes Ankit,
    This is good feature by which we can rearrange the fields on VFP with out Touching the code.

    ReplyDelete
  3. I have a field set, but one is input field other is plain output text field. How can I have these 2 fields in a field set?

    ReplyDelete
  4. Hai i am new to the salesforce,i need to know
    1)What is the difference between standard controller and custom controller?
    2)when to choose standard or custom controller?

    ReplyDelete
  5. what is the output of this snippet? in this custom object dont have custom fields(empty).

    custom_object__c co = new custom_object__c();
    insert co;

    ReplyDelete
    Replies
    1. according to the values of what u have initialized in the default constructor, that will be insert

      Delete
  6. My requirement is Update Multiselect picklist based on the lookup field in VF page.

    All are custom objectes here.

    PLease help me how to do this

    ReplyDelete
  7. excellent post, and well explained dude...

    ReplyDelete
  8. How to create a field using visualforce page.Please help me

    ReplyDelete
  9. i have created a "office address" field set same as "address" field set present in lead form.but i am unable to display that field set on leadform

    ReplyDelete
  10. Hi Ankit, I just starting using Field sets and I could not see "Available for the Field set" container itself.
    Am I missing something here, any config?

    Thanks

    ReplyDelete
  11. Very nice work, really appreciable. Good to know something new today, keep it up.
    1000 free youtube subscribers
    SMM service

    ReplyDelete
  12. his is a nice and informative, containing all information and also has a great impact on the new technology.
    best canoe tours in kerala

    ReplyDelete