You need to sign in to do that
Don't have an account?
jimc507
How to get the description of a sObject or field from Apex
is there a way to get the description from the describe functions is Apex. I have looked at the Schema.DescribeSObjectResult and Schema.DescribeFieldResult objects and did not see them. Is there another method or am I overlooking something?
Thanks in advance
Jim
Hi,
Did you try the following code :-
check the code:- String description = result.getDescription(); highlighted in red in the above code.
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
All Answers
Hi,
Did you try the following code :-
check the code:- String description = result.getDescription(); highlighted in red in the above code.
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
For everayone else, please be aware that the provided solution does not work with custom fields for any custom object, but only with certain types that provide categories, e.g.
See: http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_describedatacategorygroups.htm#sforce_api_calls_describedatacategorygroups
Select Label, QualifiedApiName, Description from FieldDefinition Where EntityDefinition.QualifiedApiName='Account'
Just use the API name for whatever custom or standard object you'd like to see field descriptions on for EntityDefinition.QualifiedApiName and ensure you have 'Use Tooling API' selected in the developer console if that's where you're running this. To run this in Apex and access the results, see https://github.com/CompassionIntl/SalesforceSchemaAuditor/blob/master/classes/FieldAuditor.cls for an example of how this would work and other metadata you can gather on fields using the Tooling API.