Apexで選択リスト取得
//取引先の種別の選択リスト取得
List<Schema.PicklistEntry> picklist = getPicklist('Account', 'Type');
for(Schema.PicklistEntry pick : picklist){
System.debug('-----------------');
System.debug('Label :' + pick.getLabel());
System.debug('Value :' + pick.getValue());
System.debug('Active:' + pick.isActive());
}
//有効な選択リスト取得
public List<Schema.PicklistEntry> getPicklist(String sObjName, String fieldName){
List<Schema.PicklistEntry> pickList;
Schema.SObjectType sObjType = (Schema.SObjectType) Schema.getGlobalDescribe().get(sObjName);
if(sObjType != null){
Map<String, Schema.SObjectField> fieldmap = sObjType.getDescribe().fields.getMap();
Schema.SObjectField f = (Schema.SObjectField) fieldmap.get(fieldName);
if(f != null){
Schema.DescribeFieldResult r = f.getDescribe();
pickList = r.getPicklistValues();
System.debug('pickList' + pickList);
}
}
return pickList;
}