1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

技術メモ:Apexから指定オブジェクトの表示ラベルとAPI名取得

Posted at

指定項目取得

String accPhoneLabel = Schema.SObjectType.Account.fields.Phone.label;

全部項目マップ取得

public static Map<String,String> getFieldLabelMap(String sObjectName){
    Map<String,String> fieldLabelMap = new Map<String,String>();

    for(Schema.SObjectField field : Schema.getGlobalDescribe().get(sObjectName).getDescribe().fields.getMap().values()){
        fieldLabelMap.put(field.getDescribe().getName(), field.getDescribe().getLabel());
    }

    return fieldLabelMap;
}
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?