Dec12th

選択リスト取得

Top / 選択リスト取得

public List<Schema.PicklistEntry> getPicklist(String obj, String item){

   List<Schema.PicklistEntry> pickList;
   Schema.SObjectType sobjtype = (Schema.SObjectType)Schema.getGlobalDescribe().get(obj);
   if(sobjtype != null){
       Map<String, Schema.SObjectField> fieldmap = sobjtype.getDescribe().fields.getMap();
       Schema.SObjectField f = (Schema.SObjectField)fieldmap.get(item);
       if(f != null){
           Schema.DescribeFieldResult r = f.getDescribe();
           pickList = r.getPicklistValues();
           System.debug('★値' + pickList);
       }
   }
   return pickList;

}