Activity Forums Salesforce® Discussions How to get field label for an object without query in Salesforce?

  • How to get field label for an object without query in Salesforce?

    Posted by Deepak on October 30, 2020 at 3:23 pm

    How to get field label for an object without query in Salesforce?

    Shweta replied 4 years ago 3 Members · 2 Replies
  • 2 Replies
  • Anjali

    Member
    November 2, 2020 at 2:31 pm
  • Shweta

    Member
    November 3, 2020 at 2:46 pm

    Try this:
    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.}

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos