function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Gourav JainGourav Jain 

use field set on our org and how can use on my visualforce page

how we create field set on our org and how can use on my visualforce page?

Best Answer chosen by Admin (Salesforce Developers) 
Navatar_DbSupNavatar_DbSup

Hi,

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 :

 

view plainprint?

<apex:page id="pageId" standardcontroller="My_Object__c"> 

<apex:form id="formId"> 

    <apex:pageblock id="pbId"> 

        <apex:pageblocksection columns="1" id="pbsIs"> 

            <apex:repeat value="{!$ObjectType.My_Object__c.FieldSets.MyFieldSet}" var="f"> 

                <apex:inputfield value="{!My_Object__c[f]}"> 

            </apex:inputfield></apex:repeat> 

        </apex:pageblocksection> 

    </apex:pageblock> 

</apex:form> 

</apex:page> 

 

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.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.