+ Start a Discussion
yunicfayunicfa 

how to get description of sobject or field from apex

hello averybody.

 

i need someone say me how i can get the description to sobject or field from apex.

there is Schema.DescribeSObjectResult and Schema.DescribeFieldResult but they dont give a method as getDescription().

my best regard!  i hope that someone help me with that ! 

rt3203rt3203

Try something like this:

 

public List<String> SList {
get {
if (SList == null) {

SList = new List<String>();
Schema.DescribeFieldResult field = Object.customfield__c.getDescribe();
for (Schema.PicklistEntry f : field.getPicklistValues())
SList.add(f.getLabel());
}
return SList;
}
set;
}

yunicfayunicfa

getPicklistValues : Returns a list of PicklistEntry objects. A runtime error is returned if the field is not a picklist.

 

and i need the description of field... not the possible values