You need to sign in to do that
Don't have an account?
kmadmin
Getting metadata information about fields in Visualforce Pages
Is there a way to get description information for a custom object field in Visualforce? I have a need to iterate over fields of a custom object and create a layout in 3 columns, column 1 - Label , column 2 - Input field, column 3- description information for that input field.
Is this possible in Visualforce? I am trying to replicate a 3 column word document in Salesforce.com.
Refer to page 138 APEX Code Developer's Guide
Accessing All Field Describe Results for an sObject
Use the field describe result's getMap method to return a map that represents the relationship between all the field names
(keys) and the field tokens (values) for an sObject.
The following example generates a map that can be used to access a field by name:
Map<String, Schema.SObjectField> M = Schema.SObjectType.Account.fields.getMap();
Something like the following will give you the object fields, through which you can retrieve various properties such as Name.
Alas it doesn't appear that the field description is exposed but perhaps you could instead use the in-line help text?
public class MyCustomController { public DescribeFieldResult[] fields { get { if (fields == null) { fields = new DescribeFieldResult[0]; for (SObjectField sf : Schema.SObjectType.MyCustomObj__c.Fields.getMap().values()) { fields.add(sf.getDescribe()); } } return fields } private set; } }