1

I want to Query Name/Help Text/Description of custom fields in a custom object. Something like:

SELECT Name, HelpText, Description FROM sboject WHERE object = XXX
1

There is no such attribute on an SObject as InlineHelpText. If you want to get the Description for a particular object, you must use the Metadata API. You would think you could get it using describes, but you would be wrong. That attribute is curiously missing from the DescribeSObjectResult class.

Before using this code, you must install the Apex Wrapper Salesforce Metadata API and set up its Remote Site Settings. Then you can do:

MetadataService.MetadataPort service = new MetadataService.MetadataPort();
service.SessionHeader = new MetadataService.SessionHeader_element();
service.SessionHeader.sessionId = UserInfo.getSessionId();

MetadataService.CustomObject customObject = (MetadataService.CustomObject)service.readMetadata(
    'CustomObject', new List<String>{'MyObject__c'}
).getRecords()[0];
system.debug(customObject.description);

As for specific fields, you can see a similar conclusion about the Description for a field posted years ago here:

How to get a field's description via API?

However, as noted there, you can get the InlineHelpText of a field simply from its describe:

String helpText = MyObject__c.MyField__c.getDescribe().getInlineHelpText();
0

With the Tooling API and you can use the below query to get Custom Field Metadata including Help Text:

SELECT Id, EntityDefinition.QualifiedApiName, DeveloperName, RelationshipLabel, Description, InlineHelpText, DefaultValue, CreatedDate, LastModifiedDate, Length, Precision, Scale, SummaryOperation, TableEnumOrId
FROM CustomField
Where EntityDefinition.QualifiedApiName IN ('Account', 'Lead', 'Contact', 'Opportunity', 'User', 'Asset', 'Launch__c', 'Campaign')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.