You need to sign in to do that
Don't have an account?
Ken_Koellner
Query for possible values for Picklist or Multiple picklist
I would like to query the possible values for a picklist to put up a mutli-select field on my page. Is there a way to query for the possible values for a simple picklist?
Also, I'd like to do the same for a multi-select picklist. I know this was asked before and it wasn't possible in the past. Is there any way to do it now?
Schema.DescribeFieldResult fieldResult = OpportunityLineItem.UpgradeCode__c.getDescribe();
List<Schema.PicklistEntry> picklistEntries = fieldResult.getPicklistValues();
List<SelectOption> options = new List<SelectOption>();
for (Schema.PicklistEntry entry : picklistEntries)
options.add(new SelectOption(entry.getLabel(), entry.getValue()));
All Answers
see http://www.salesforce.com/us/developer/docs/api/index.htm
describeSObjectResult -> Field -> picklistValues
Schema.DescribeFieldResult fieldResult = OpportunityLineItem.UpgradeCode__c.getDescribe();
List<Schema.PicklistEntry> picklistEntries = fieldResult.getPicklistValues();
List<SelectOption> options = new List<SelectOption>();
for (Schema.PicklistEntry entry : picklistEntries)
options.add(new SelectOption(entry.getLabel(), entry.getValue()));