[SalesForce] Get Object Custom Fields base on its Description or Help Text

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());

Best Answer

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...

Related Topic