You need to sign in to do that
Don't have an account?
ClintProd
Getting picklist options
Does anyone have any clear examples for getting the options from a picklist from either a standard Salesforce object or a custom object? I am sure I have to use one of the describe commands to do this, but I cannot find any examples for this. Thanks.
Picklist fields contain a list of one or more items from which a user chooses a single item. They display as drop-down lists in the Salesforce user interface. One of the items can be configured as the default item.
In the Field object associated with theDescribeSObjectResult, the restrictedPicklist field defines whether the field is a restricted picklist or not. The API does not enforce the list of values for advisory (unrestricted) picklist fields on create or update. When inserting an unrestricted picklist field that does not have a PickListEntry, the system creates an “inactive” picklist value. This value can be promoted to an “active” picklist value by adding the picklist value in the Salesforce user interface.
When creating new, inactive picklists, the API checks to see if there is a match. This check is case-insensitive.
In the Field object associated with theDescribeSObjectResult, the PicklistValues field contains an array of items (PickListEntry objects). Each PickListEntry defines the item’s label, value, and whether it is the default item in the picklist (a picklist has no more than one default value).
Enumerated fields support localization of the labels to the language of the user. For example, for the ForecastCategory field on an Opportunity, the value “Omitted” may be translated to various languages. The enumerated field values are fixed and do not change with a user’s language. However, each value may have a specified “label” field that provides the localized label for that value. You must always use the value when inserting or updating a field. The query call always returns the value, not the label. The corresponding label for a value in theDescribeSObjectResult should be used when displaying the value to the user in any user interface.
The API supports the retrieval of the certain picklists in the following objects: CaseStatus, ContractStatus, LeadStatus, OpportunityStage, PartnerRole, SolutionStatus, TaskPriority, and TaskStatus. Each object represents a value in the respective picklist. These picklist entries always specify some other piece of information, such as whether the status is converted, and so on. Your client application can invoke the query call on any of these objects (such as CaseStatus) to retrieve the set of values in the picklist, and then use that information while processing other objects (such as Cases) to determine more information about those objects (such as a given case). These objects are read-only via the API. To modify items in picklists, you must use the Salesforce user interface.