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

Get Field Description in Apex Code


Is there any way to get description of all fields of an object in apex code?
Able to query inline text help, label, api name, length etc, but not the description.
Any workaround/trick ?

Hi , 

You have to use the describe calls to get all the details of a field. 

See the links below,

Is there anyway to get the name/label of a field without doing a field describe?

getting Value of a field by its Name in apex salesforce

Vishant ShahVishant Shah
Map<String, Schema.SObjectField> fMap = Schema.getGlobalDescribe().get(objectName.toLowerCase()).getDescribe().Fields.getMap();
        list<string> selectFields = new list<string>();
        if (fMap != null){
            for (Schema.SObjectField ft : fMap.values()){ // loop through all field tokens (ft)
                Schema.DescribeFieldResult fd = ft.getDescribe(); // describe each field (fd)
                system.debug(fd); /// your field action here
This is the code you need 
Anup ShindeAnup Shinde
You cannot get the Description using Describe calls in APEX.

A trick (and a very difficult one) is to use the Metadata API. You can do this via APEX - but the process is async. Since you want to fetch the information, it would require "retrieve" calls - and those are seriously difficult to do in APEX.

FYI I raised this as an issue with the Salesforce product manager a couple of weeks ago who was surprised it wasn't available in describe calls and is looking to get it in the roadmap.
Hi All, 

The Idea: Object/Field Description text available to API and APEX Describe call , please vote for the same.

Also See the blog: Getting Salesforce Field Metadata the Easy Way


As an alternate solution, i am trying to maintain a excel/csv file under SF documents/StaticResource. This excel file will contain the description.
But not sure how to GET and DISPLAY that excel file in VF Page. Any ideas ?
TC DeveloperTC Developer read the file and do the needful 
Joe Markey 6Joe Markey 6
I was able to get sObject metadata using the following:

public class SObjectMetadata {
        public String fieldName {get;set;}
        public Schema.DisplayType fieldType {get;set;}
        public String sObjectName {get;set;}
        public SObjectMetadata(String pFieldName, Schema.DisplayType pFieldType, String pSobjectName) {
            this.fieldName = pFieldName;
            this.fieldType = pFieldType;
            this.sObjectName = pSobjectName;

    public static String getsObjectMetadata(String pSobject) {
        List<SObjectMetadata> sObjectMetadataList = new List<SObjectMetadata>();
        Map<String, Schema.SObjectField> fieldMap = Schema.getGlobalDescribe().get(pSobject).getDescribe().fields.getMap();
        for(Schema.SObjectField ft : fieldMap.values()) {
            Schema.DescribeFieldResult fd = ft.getDescribe();
            sObjectMetadataList.add(new SObjectMetadata(fd.getName(), fd.getType(), pSobject));
        return JSON.serialize(sObjectMetadataList);
Tristyn MaaloufTristyn Maalouf
You can get field descriptions from the Tooling API with the following query:

Select Label, QualifiedApiName, Description from FieldDefinition Where EntityDefinition.QualifiedApiName='Account'

Where EntityDefinition.QualifiedApiName is the api name of the object you're interested in. Then, to run this query in Apex and get the results, you can establish an Http connection and send the query to the tooling api like so:

req.setEndpoint(instanceName + '/services/data/v48.0/tooling/query/?q=Select+EntityDefinition.DurableId,Label,DeveloperName,DurableId,QualifiedApiName,DataType,Description+from+FieldDefinition+Where+EntityDefinition.QualifiedApiName=\'' + selectedObject + '\'');       

Again selectedObject would be your object's API name. Then you can deserialize the Json response of the query and access the data. For a full example of this check out Salesforce Field Auditor (