Newer Version Available

This content describes an older version of this product. View Latest

Picklist (Including Dependent Picklist)

Deprecated. Represents a picklist (or dependent picklist) definition for a custom field in a custom object or a custom or standard field in a standard object, such as an account.

Version

Use this type in API version 37.0 and earlier only. Picklists for custom fields in custom objects are available in API version 12.0 and later. Picklists for custom or standard fields in standard objects, such as accounts, are available in API version 16.0 and later.

In API version 38.0 and later, Picklist is replaced by ValueSet on the CustomField type.

Declarative Metadata File Suffix and Directory Location

Picklist definitions are included in the custom object and field with which they’re associated.

Fields

Picklist contains the following fields:

Field Name Field Type Description
controllingField string The fullName of the controlling field if controllingField is a dependent picklist. A dependent picklist works in conjunction with a controlling picklist or checkbox to filter the available options. The value chosen in the controlling field affects the values available in the dependent field. This field is available in API version 14.0 and later.
picklistValues PicklistValue[]

Required. Represents a set of values for a picklist.

restrictedPicklist boolean Indicates whether the picklist’s value list is restricted. With a restricted picklist, only an admin can add or change values; users can’t load or remove values through the API. By default this value is false.

This field is available in API version 37.0 and later.

sorted boolean

Indicates whether values are sorted (true), or not (false). By default this value is false.

Java Sample

The following sample uses a picklist. For a complete sample of using a picklist with record types and profiles, see Profile.

1public void setPicklistValues() {
2  // Create a picklist
3  Picklist expenseStatus = new Picklist();
4  PicklistValue unsubmitted = new PicklistValue();
5  unsubmitted.setFullName("Unsubmitted");
6  PicklistValue submitted = new PicklistValue();
7  submitted.setFullName("Submitted");
8  PicklistValue approved = new PicklistValue();
9  approved.setFullName("Approved");
10  PicklistValue rejected = new PicklistValue();
11  rejected.setFullName("Rejected");
12  expenseStatus.setPicklistValues(new PicklistValue[]
13      {unsubmitted, submitted, approved, rejected});
14  
15  CustomField expenseStatusField = new CustomField();
16  expenseStatusField.setFullName(
17      "ExpenseReport__c.ExpenseStatus__c");
18  expenseStatusField.setLabel("Expense Report Status");
19  expenseStatusField.setType(FieldType.Picklist);
20  expenseStatusField.setPicklist(expenseStatus);
21  try {
22    AsyncResult[] ars =
23    metadataConnection.create(new Metadata[] {expenseStatusField});
24  } catch (ConnectionException ce) {
25    ce.printStackTrace();
26  }
27}

Wildcard Support in the Manifest File

This metadata type doesn’t support the wildcard character * (asterisk) in the package.xml manifest file. For information about using the manifest file, see Deploying and Retrieving Metadata with the Zip File.