[SalesForce] Displaying custom field description on VF page

I have a requirement where the names of the custom fields far exceed the 40 characters limit. So instead I thought I would put a keyword in the field name and the whole name in the description of the field. Is there possibly a way, to print the description of a field on the VF page? I could have done it manually too but the number of fields is close to 100 and making so many manual entries on the VF page isn't the best approach.

Someone please help!

Best Answer

You can fetch the Description but it will require quite some digging into the metadata API. I'd suggest using the HelpText for this and replacing the label for a field by the helptext, which is available directly in VisualForce. E.g.:

<apex:pageBlockSectionItem >
    <apex:outputLabel value="{!$ObjectType.Account.fields.Street__c.InlineHelpText}"/>
    <apex:outputField value="{!a.Street__c}"/>
</apex:pageBlockSectionItem>
Related Topic