Activity Forums Salesforce® Discussions How to get labels of field for an object in Salesforce?

  • How to get labels of field for an object in Salesforce?

    Posted by Deepak on October 27, 2020 at 3:48 pm

    How to get labels of field for an object in Salesforce?

    Nitesh replied 4 years ago 3 Members · 2 Replies
  • 2 Replies
  • Ayush

    Member
    October 28, 2020 at 5:45 am

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

  • Nitesh

    Member
    October 28, 2020 at 10:20 am

    system.debug( 'Field Label Name is ' + Opportunity.StageName.getDescribe().getLabel() );

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos