---
schema_version: "1"
id: 429055402ce1e9c2dadb26c7a17167f48c08cbe7e4a869260804861d9e955892
title: DynamicPickList Class
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_class_VisualEditor_DynamicPickList.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_VisualEditor_DynamicPickList.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 78f3673521c48468f6bdddb50def1a84153d6cfcfce01cb441d0366901959c30
description: An abstract class, used to display the values of a picklist in a Lightning component on a Lightning page.Makes a duplicate copy of the VisualEditor.DynamicPicklist object.Returns the picklist item that is set as the default value for the picklist.Returns the user-facing label for a specified picklist value.Returns the list of picklist item values.Returns the valid state of the picklist item’s value. A picklist value is considered valid if it’s a part of any VisualEditor.DataRow in the VisualEditor.DynamicPickListRows returned by getValues().
---
# DynamicPickList Class

An abstract class, used to display the values of a picklist in a Lightning component on a Lightning page.

## Namespace

[VisualEditor](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_VisualEditor.htm#apex_namespace_VisualEditor "The VisualEditor namespace provides classes and methods for interacting with the Lightning App Builder. The classes and methods in this namespace operate on Lightning components, which include Lightning web components and Aura components.")

## Usage

To use this class as the datasource of a picklist in a Lightning component, it must be extended by a custom Apex class and then that class must be called in the component’s design file.

## Example

Here’s an example of a custom Apex class extending the VisualEditor.DynamicPickList class.

global with sharing class MyCustomPickList extends VisualEditor.DynamicPickList{
    
    global override VisualEditor.DataRow getDefaultValue(){
        VisualEditor.DataRow defaultValue = new VisualEditor.DataRow('red', 'RED');
        return defaultValue;
    }
    global override VisualEditor.DynamicPickListRows getValues() {
        VisualEditor.DataRow value1 = new VisualEditor.DataRow('red', 'RED');
        VisualEditor.DataRow value2 = new VisualEditor.DataRow('yellow', 'YELLOW');
        VisualEditor.DynamicPickListRows  myValues = new VisualEditor.DynamicPickListRows();
        myValues.addRow(value1);
        myValues.addRow(value2);
        return myValues;
    }
}

Here’s an example of how the custom Apex class gets called in a design file so that the picklist appears in the Lightning component.

<design:component\>
        <design:attribute name="property1" datasource="apex://MyCustomPickList"/>
</design:component\>

- **[DynamicPickList Methods](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_VisualEditor_DynamicPickList.htm#apex_VisualEditor_DynamicPickList_methods)**

## DynamicPickList Methods

The following are methods for DynamicPickList.

- **[clone()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_VisualEditor_DynamicPickList.htm#apex_VisualEditor_DynamicPickList_clone)**  
    Makes a duplicate copy of the VisualEditor.DynamicPicklist object.
- **[getDefaultValue()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_VisualEditor_DynamicPickList.htm#apex_VisualEditor_DynamicPickList_getDefaultValue)**  
    Returns the picklist item that is set as the default value for the picklist.
- **[getLabel(attributeValue)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_VisualEditor_DynamicPickList.htm#apex_VisualEditor_DynamicPickList_getLabel)**  
    Returns the user-facing label for a specified picklist value.
- **[getValues()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_VisualEditor_DynamicPickList.htm#apex_VisualEditor_DynamicPickList_getValues)**  
    Returns the list of picklist item values.
- **[isValid(attributeValue)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_VisualEditor_DynamicPickList.htm#apex_VisualEditor_DynamicPickList_isValid)**  
    Returns the valid state of the picklist item’s value. A picklist value is considered valid if it’s a part of any VisualEditor.DataRow in the VisualEditor.DynamicPickListRows returned by getValues().

### clone()

Makes a duplicate copy of the VisualEditor.DynamicPicklist object.

#### Signature

public Object clone()

#### Return Value

Type: Object

### getDefaultValue()

Returns the picklist item that is set as the default value for the picklist.

#### Signature

public VisualEditor.DataRow getDefaultValue()

#### Return Value

Type: [VisualEditor.DataRow](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_VisualEditor_DataRow.htm#apex_class_VisualEditor_DataRow "Contains information about one item in a picklist used in a Lightning component on a Lightning page.")

### getLabel(attributeValue)

Returns the user-facing label for a specified picklist value.

#### Signature

public String getLabel(Object attributeValue)

#### Parameters

- **attributeValue**: Type: Object The value of the picklist item.

#### Return Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### getValues()

Returns the list of picklist item values.

#### Signature

public VisualEditor.DynamicPickListRows getValues()

#### Return Value

Type: [VisualEditor.DynamicPickListRows](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_VisualEditor_DynamicPickListRows.htm#apex_class_VisualEditor_DynamicPickListRows "Contains a list of picklist items in a Lightning component on a Lightning page.")

### isValid(attributeValue)

Returns the valid state of the picklist item’s value. A picklist value is considered valid if it’s a part of any VisualEditor.DataRow in the VisualEditor.DynamicPickListRows returned by getValues().

#### Signature

public Boolean isValid(Object attributeValue)

#### Parameters

- **attributeValue**: Type: Object The value of the picklist item.

#### Return Value

Type: [Boolean](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_boolean.htm#apex_methods_system_boolean "Contains methods for the Boolean primitive data type.")