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

  • How to get the Label Names for Object's fields in Salesforce?

    Posted by PRANAV on October 14, 2016 at 1:58 pm

    Hi All,

    How to get the Label Names for Object's fields?

    Actually I want the object's field label name dynamically  and is wanted in a select list option through coding.

    Thanks

    • This discussion was modified 8 years, 2 months ago by  PRANAV.
    • This discussion was modified 8 years, 2 months ago by  Forcetalks.
    • This discussion was modified 8 years, 2 months ago by  Forcetalks.
    Ashley replied 8 years, 2 months ago 3 Members · 2 Replies
  • 2 Replies
  • 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:

    https://www.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