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?

  • PRANAV

    Member
    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 5 years, 1 month ago by  PRANAV.
    • This discussion was modified 5 years, 1 month ago by  Forcetalks.
    • This discussion was modified 5 years, 1 month ago by  Forcetalks.
  • 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.

Viewing 1 - 3 of 3 posts

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos