You need to sign in to do that
Don't have an account?
yunicfa
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 !
Hello,
Yes the method getDesciption is available for different contexts. For example:
for(DescribeDataCategoryGroupResult singleResult : describeCategoryResult){
//Getting description
singleResult.getDescription();
//Getting the sobject
singleResult.getSobject();
}
For details please refer the section "Understanding Apex Describe Information" under "Dynami Apex" section in the following link:
http://www.salesforce.com/us/developer/docs/apexcode/
thnx for reply.
i walked trough your answer before post my question .. and i didnt get any result ! .. please can you tell me hw i can get the description for example
Custom Object Exam with Field Description and the description of this field is Description of field
Hw i can get the string Description of field using your solution
Thnx a lot !
Below Link would be helpful for you : Understanding Apex Describe Information - Salesforce.com
Here you will get all the fields API.
String sfields= '';
Map<String, Schema.SObjectField> objectFieldMap = Schema.getGlobalDescribe().get('ObjectAPI').getDescribe().fields.getMap();
for(Schema.SObjectField column: objectFieldMap.values()) {
sQuery += column+', ';
}
system.debug(sfields); // here u can see all fields API.
where did u use sfileds ???? in
Map objectFieldMap =
Schema.getGlobalDescribe().get('ObjectAPI').getDescribe().fields.getMap();
for(Schema.SObjectField column: objectFieldMap.values()) {
sQuery += column+', ';
}
*
*
* Yunier Cordovi Figueroa*
SKYPLANNER TEAM
www.theskyplanner.com
209.878.7363
ycordovi@theskyplanner.com
8180 NW 36 St, Suite 422 Doral, FL 33166
String sfields= '';
Map<String, Schema.SObjectField> objectFieldMap = Schema.getGlobalDescribe().get('ObjectAPI').getDescribe().fields.getMap();
for(Schema.SObjectField column: objectFieldMap.values()) {
sfields+= column+', ';
}
system.debug(sfields); // here u can see all fields API.
its not works for me .. coz i need the drescription not the names ! htnx anyway !
i have misunderstand before, now you can try this code.
Map<String, Schema.SObjectField> objectFieldMap = Schema.getGlobalDescribe().get('Contact').getDescribe().fields.getMap();
List<String> fieldList =new List<String>();
for(String fieldName:objectFieldMap.keySet()) {
Schema.DescribeFieldResult fieldDescribe = objectFieldMap.get(fieldName).getDescribe();
system.debug('fieldDescribe --->' +fieldDescribe );
fieldList.add(fieldDescribe.getName());
}
Make sure you have 'Use Tooling API' selected. To run this query via apex and deserialize the results so that you can access them in Apex see https://github.com/CompassionIntl/SalesforceSchemaAuditor/blob/master/classes/FieldAuditor.cls