1

Is there a way to get the Object Custom Fields using the Field Description or Help Text..

Example:

I created a Custom Field and put a Description "Get Field". I can get all the Custom Field using the "Get Field" Description.

This is my apex now:

List<string> fieldlist = new List<string>();

fieldlist.addAll(Custom_Object__c.SObjectType.getDescribe().fields.getMap().keySet());
2

Below is the code to get the help text. For account.

Map<String,List<String>> allField = new Map<String,List<String>>();
      Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();    
        Map <String, Schema.SObjectField> fieldMap = gd.get('Account').getDescribe().fields.getMap();

        for(Schema.SObjectField fieldAPI : fieldMap.values())
        {  
          //    Schema.DescribeFieldResult dfield = fieldAPI.getDescribe();
            System.debug('Help Text' + fieldAPI.getDescribe().getInlineHelpText());

        }

Just create a map or a list and add the field you want if the help text is correct. BGN...

|improve this answer|||||
  • How to get field description text? – Roul Apr 29 '19 at 5:27
1

If I understand it correctly, I think this should work:

String obj='Custom_Object__c';
Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
Schema.SObjectType leadSchema = schemaMap.get(obj);
Map<String, Schema.SObjectField> fieldMap = leadSchema.getDescribe().fields.getMap();
String s = '';

for (String fieldName: fieldMap.keySet()) {
s += fieldMap.get(fieldName).getDescribe().getLabel() + '\t' +
 fieldMap.get(fieldName).getDescribe().getInlineHelpText()+'\n';
}

system.debug(s);

You can put your condition inside the loop.

|improve this answer|||||

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.