function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ken_KoellnerKen_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?

 

Best Answer chosen by Admin (Salesforce Developers) 
AltiumForceAltiumForce


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

dev_forcedev_force

see http://www.salesforce.com/us/developer/docs/api/index.htm

 

describeSObjectResult -> Field -> picklistValues

 

AltiumForceAltiumForce


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()));

This was selected as the best answer