+ Start a Discussion

Creating the list of fields of contact added to particular layout.



I have to create the list of custom as well as some standard fields of contact, which are added to a layout.

I also need to discard standard fields such as createdID etc. and formula fields.

Currently I am using describeSobject and able to retreive all the fields on contacts.


Please help me, it is urgent.


With Regards

Palak Agarwal


Hi Palak,


The below is an example from VF Developer Guide : Chapter "Dynamic Visualforce Bindings"


public class DynamicAccountFieldsLister {
public DynamicAccountFieldsLister(ApexPages.StandardController controller) {
public List<String> editableFields {
get {
if (editableFields == null) {
editableFields = new List<String>();
return editableFields ;
private set;


<apex:page standardController="Account"
<apex:pageMessages /><br/>
<apex:pageBlock title="Edit Account" mode="edit">
<apex:pageBlockSection columns="1">
<apex:inputField value="{!Account.Name}"/>
<apex:repeat value="{!editableFields}" var="f">
<apex:inputField value="{!Account[f]}"/>







You can create a list of string (I.e. fields) which will contain only those fields which you want to show on the VFpage. You have to simply make the condition inside the controller.


Please go through the link below:


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

palak agarwalpalak agarwal

Thanks S Jain for your reply. The problem I am facing is I am able to retrieve the list of fields through the link you send but I want the list of those fields which are there in a particular layout not all the fields.


I have created a pagelayout for contacts and added few fields on this layout. Now I want the list of only these fields which are present in this layout. Is it possible?


You can't get at that type of information, as Apex doesn't provide access to the metadata API.


This sounds like a case for field sets - you'll have to maintain the list of fields in particular page layout in a separate place, but it does allow changes without writing code.


Here's a blog post of mine that gives an example of using them: