Activity Forums Salesforce® Discussions How to get the Label Names for Object's fields in Salesforce?

  • Tanu

    Member
    October 18, 2016 at 6:46 am

    Hello Pranav,

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

  • Ashley

    Member
    October 19, 2016 at 12:28 am

    This is well explained at the following link:

    http://stage.forcetalks.com/salesforce-topic/how-to-get-the-label-names-for-objects-field/

    Hope this helps.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos