function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jayaramu T 9Jayaramu T 9 

I want to use the custom labels in apex class for fetching the case object fields following below. can any one please help me on this?

Account Name
Contact Name
Subject
Issue Summary
Case Record Type
Raj VakatiRaj Vakati
You need to use the dynamic apex 
 
String type='Account';

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


for (String fieldName: fieldMap.keySet()) {

System.debug('##Field API Name='+fieldName);// list of all field API name

 

fieldMap.get(fieldName).getDescribe().getLabel();//It provides to get the object fields label.
}

Refer

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_dynamic_vf_globals_objecttype.htm

https://www.forcetalks.com/salesforce-topic/how-to-get-the-label-names-for-objects-fields-in-salesforce/

http://amitsalesforce.blogspot.com/2015/11/apex-describe-dynamic-retrieval-of.html​​​​​​​