Get Field Label With API name using Describe Call




Map<String,String> mapFieldLebelToApiName = new Map<String,String>();



Map<String, Schema.SObjectField> fieldsMap = Schema.SObjectType.SobjectName.fields.getMap();
      system.debug('fieldsMap****'+fieldsMap);
       system.debug('fieldsMapvalues****'+fieldsMap.values());
      for (Schema.SObjectField field : fieldsMap.values()){
      
           mapFieldLebelToApiName .put(field.getDescribe().getLabel(), field.getDescribe().getName());
        
          
      }   

Comments

Popular Post

Salesforce Spring '26 Release High level points

Get the record Count of all countable Sobjects in Salesforce

Fetch record type-specific picklist values directly in Apex