# Picklist

## Overview

The Picklist Data Source enables you to connect input components within your Avonni Dynamic Components to standard or custom picklist fields in your Salesforce organization. This provides a seamless way to present users with pre-defined choices, ensuring data consistency and a user-friendly experience. The Picklist data source also supports record types.

This offers several advantages:

* **Data Consistency:** Ensures that users can only select valid values defined in your Salesforce picklists.
* **Automatic Updates:** If the picklist values in Salesforce are updated, the changes are automatically reflected in your Dynamic Component (no manual updates required).
* **Simplified Configuration:** Reduces development time by leveraging existing Salesforce configuration.
* **Record Type Support:** The Picklist Data Source respects record type restrictions. If record types control a picklist field's values, the component will display only the values appropriate for the current record's record type (if applicable).
* **Picklist Filtering Based on Current Record Value:** You can now filter picklist options based on the current record’s field value, ensuring even more relevant choices for users.

***

## Supported Components

You can use the Picklist Data Source with Avonni components designed for selecting options, such as:

* [**Combobox**](https://docs.avonnicomponents.com/dynamic-components/components/combobox)
* [**Dual Listbox**](https://docs.avonnicomponents.com/dynamic-components/components/dual-listbox)
* [**List**](https://docs.avonnicomponents.com/dynamic-components/components/list)
* [**Visual Picker**](https://docs.avonnicomponents.com/dynamic-components/components/visual-picker)
* And potentially others

***

## How it Works

1. **Component Configuration:** Within your Avonni Dynamic Component, select an input component that supports the Picklist Data Source (e.g., Combobox).
2. **Select Data Source:** In the component's properties panel, locate the "Data Source" setting (or a similar option) and select "Picklist."
3. **Configure the Picklist Data Source:**
   * **Object API Name:** Select the Salesforce object that contains the picklist field you want to use (e.g., `Account`, `Opportunity`, `My_Custom_Object__c`).
   * **Field API Name:** Select the specific *picklist field* from that object (e.g., `Industry`, `StageName`, `My_Custom_Picklist__c`).
   * **Record Type ID (Optional):** If record types control the picklist field's values, you can *optionally* provide a Record Type ID. This is typically done dynamically:
     * You'll usually get this ID from a variable or resource within your Dynamic Component, most likely from the `@recordId` (if on a record page) combined with a "Get Records" on the `RecordType` object to get the correct ID.
     * If you leave the Record Type ID blank, and there are Record Types, the component may show no picklist options.
     * If you leave the Record Type ID blank, and no Record Type are defined on the object, the component will display the values.
   * **Picklist Values Attribute (Optional)**\
     We've added a new attribute called **Picklist Values**, which lets you explicitly control which picklist options are displayed.
     * You can pass values from the current record (e.g., `component.record.picklistvalue`) to filter the options based on that record's existing data.
     * If you leave **Picklist Values** empty, all available options will be shown by default.
4. **Automatic Population:** The component automatically retrieves valid picklist values (based on the object, field, and optional record type) and displays them as options to the user.

***

## Use Cases

Here are some examples of how you can use the Picklist Data Source:

* **Account Industry Selection:** On an Account record page, use a Combobox component connected to the `Industry` picklist field on the `Account` object.
* **Opportunity Stage Selection:** In a component for updating Opportunities, use a Combobox or Radio Button Group connected to the `StageName` picklist on the `Opportunity` object.
* **Custom Object Picklists:** Use the Picklist Data Source with any custom picklist field on any custom object.
* **Case Origin Selection**: You could have a custom picklist to set values on a case record page.

***

## Important Considerations

* **Picklist Updates:** Changes to the picklist values in Salesforce (such as adding, removing, or modifying options) will be automatically reflected in your Dynamic Component.
* **Record Type Dependencies:** If the picklist field has record type dependencies, ensure you provide the correct Record Type ID (or handle the scenario where no record type is specified).
* **Multi-Select Picklists:** Some Avonni components (like Dual Listbox) can be used with *multi-select* picklist fields.
* **Access Control**: The picklist values visible will respect user access and field level security.
* **Picklist Values Attribute:** When used, only the specified values are displayed. Leaving this attribute empty shows all available values.

***

## **In Summary**

The Picklist Data Source is a simple yet powerful way to integrate your Avonni Dynamic Components with your existing Salesforce picklist configuration. It promotes data consistency, simplifies development, and ensures that your components always display the most up-to-date picklist options.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.avonnicomponents.com/dynamic-components/component-builder/data-sources/picklist.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
