# Visual Picker

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FphPhKveu6gfUPq9nMcAT%2Fimage%20(32).avif?alt=media&#x26;token=f673a561-4db0-4b99-bddc-e4dbf515310d" alt="" width="375"><figcaption></figcaption></figure>

***

## Configuring the Visual Picker

The initial step in setting up the Visual Picker is determining how you want to retrieve and display your data.

### **Data Source**

The "[Data Source Configuration](https://docs.avonnicomponents.com/flow/flow-components/broken-reference)" step in setting up the Visual Picker is where you tell the Visual Picker where to get its information from within Salesforce.

<table><thead><tr><th width="183">Data Source Type</th><th>Use Case</th><th>When to Use</th></tr></thead><tbody><tr><td><a href="../component-builder/data-sources/manual"><strong>Manual</strong></a></td><td>For a predefined set of items that don’t require dynamic updates.</td><td>Ideal for static content or rapid setup with specific items.</td></tr><tr><td><a href="../component-builder/data-sources/variable"><strong>Variable</strong></a></td><td>Dynamically displaying items based on variable collections in Salesforce.</td><td>Suitable when list content reflects changing data from Salesforce records.</td></tr><tr><td><a href="../component-builder/data-sources/picklist"><strong>Picklist</strong></a></td><td>Displaying a list of options defined in a Salesforce picklist.</td><td>Best for presenting a list of predefined options for selection.</td></tr><tr><td><a href="../component-builder/data-sources/query"><strong>Query</strong></a></td><td>Fetching data based on a specific query, pulling various records or data points.</td><td>Ideal for complex data retrieval or when sourcing. Using a 'Get Records' collection is not necessary with this method, as the query itself is powerful enough to simplify your flow</td></tr></tbody></table>

{% hint style="info" %}
Images can not be added to picklist value items.
{% endhint %}

### Data Mappings

When using a dynamic data source for your Visual Picker, you must configure the **Data Mappings** section to tell the component how to create picker items from your data.

Think of it like a translator: Data Mappings ensure the correct information from your Salesforce data.

#### **Why are Data Mappings Important?**

Without data mapping, the Visual Picker wouldn't know which part of your data to use. This could result in the Visual Picker showing incorrect or irrelevant information.

#### **How Do Data Mappings Work?**

In the Data Mappings section, you'll establish the connection between your Salesforce data fields and the corresponding List attributes. By selecting which field maps to which attribute (for example, the "Account Name" field to the "Title" attribute), you ensure each item accurately displays the correct information from your Salesforce data.

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FoP2hB2EeRGaQdwhtWduQ%2F2024-07-04_10-39-32.png?alt=media&#x26;token=11343ac1-678e-4b96-81d0-90fed18cb3c2" alt=""><figcaption></figcaption></figure>

***

## Changing the Properties

### Selecting Radio or Checkbox type

The type attribute allows you to define how the input selection should behave. To allow users to select more than one option, use **`checkboxes`** instead of **`radio`** buttons.&#x20;

### **Selection Range Customization**

The Visual Picker components now include a 'Selection Range Customization' feature, enhancing your control over item selection. This feature allows you to define minimum and maximum selection limits, particularly useful when utilizing the Checkbox Type.&#x20;

By setting these parameters, you can precisely manage the number of options a user can select, ensuring adherence to your specified range and enhancing the accuracy of data collection or user input.

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FuKJwKJDT3XEvEUR5smsH%2F2024-02-04_14-42-04%20(1).gif?alt=media&#x26;token=f066f2a2-0089-4078-bbd0-2ce76f9aa87d" alt=""><figcaption></figcaption></figure>

### Setting a Ratio

You can access various ratio values to decide how to dispose of your items.&#x20;

### Choosing a Variant

The Variant attribute lets you decide the appearance of an item when selected.&#x20;

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FddzDJsItFHYou4goawOE%2F2022-11-01_21-21-14.png?alt=media&#x26;token=8c9b824d-8c1c-48c8-aa75-ec155d169286" alt="" width="201"><figcaption><p>Non coverable vs Coverable variant</p></figcaption></figure>

## Adding Interactions

Interactions define what happens when users interact with the visual picker component. A list of [interactions is available](https://docs.avonnicomponents.com/flow/tutorials/interactions).

Here are the available interactions for the visual picker component:

* On **`Change`**: The event fired when the slider value changed.

***

## Accessing the selected value

You can reference the attribute to use the selected value from the Vertical Visual Picker in your flow. This attribute holds the currently selected item(s) from the picker.

**Example:**

1. **In your flow:** After the Vertical Visual Picker component in your flow, add a Display Text component.
2. **Configure the Display Text component:** In the 'Value' field of the Display Text component, use the formula `{!Visual_Picker.value}` (replace "Visual\_Picker" with the actual API name of your  Visual Picker component).
3. **Run the flow:** When you make a selection in the Vertical Visual Picker, the Display Text component will show the selected value(s).

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FdF9cxacrzpHJlhKMdgfp%2F2024-09-28_13-23-34%20(1).gif?alt=media&#x26;token=d6b233de-f85c-4531-ae30-823383641cc0" alt=""><figcaption><p>Example of displaying the accessing value on a text element.</p></figcaption></figure>

**Key Points:**

* **Data Type:** The `value` attribute's data type depends on your Visual Picker's configuration:
  * **Single Selection (Radio buttons):** The `value` will be a single value (e.g., the ID or label of the selected item).
  * **Multiple Selection (Checkboxes):** The `value` will be a list of values (e.g., an array of IDs or labels of the selected items).
* **`valueCollection` and `valueCollectionSerialized`:**
  * **`valueCollection`**:  When selected, the `value` attribute will give you a list of the selected items' values. This is helpful if you need to use those values in other parts of your flow.
  * **`valueCollectionSerialized`**: When this is selected, the `value` attribute will give you a text version of the list of selected items, formatted like this: `["Banking","Biotechnology","Chemicals"]`. This format is helpful if you need to store or send the selected data in a specific way.
* **Further Processing:** You can use the retrieved `value` in subsequent flow elements for further processing, decision-making, or data updates

***

## Output Variables

The Visual Picker exposes several output variables you can reference in your flow after the screen. To use them, select the screen element in Flow Builder, then the Visual Picker component, and pick the output variable you need.

### Selection

When users select one or more items in the Visual Picker, these variables capture the selection.

| Output variable                 | Type                           | What it returns                                                                                                                             |
| ------------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
| **Selected Item**               | Record (SObject)               | The Salesforce record of the last item the user selected. When the picker is in single-select mode, this is the one selected item.          |
| **Selected Items**              | Record Collection (SObject\[]) | All currently selected items as a collection of Salesforce records. Use this when the picker allows multiple selections.                    |
| **Value**                       | Text (String)                  | The value of the selected item (typically the record ID or a custom value). When single-select, this is the value of the one selected item. |
| **Value Collection**            | Text Collection (String\[])    | All selected values as a list of strings. Available when the picker is in multi-select mode.                                                |
| **Value Collection Serialized** | Text (String)                  | The selected values as a JSON string. Useful for passing to an Apex action or subflow.                                                      |

> **Example:** A user selects a service tier from a Visual Picker (Basic, Standard, Premium). Use **Value** to store the selection in a flow variable and route the flow to the appropriate configuration screen using a **Decision** element.

{% hint style="info" %} **Which output should I use?**

* Need the full record? → **Selected Item** (single) or **Selected Items** (multiple)
* Need just the value? → **Value** (single) or **Value Collection** (multiple)
* Passing to Apex? → **Value Collection Serialized** (JSON string) {% endhint %}

### Item Clicks

When users click on a Visual Picker item (distinct from selecting — useful for triggering navigation or detail views), these variables identify which item was clicked.

| Output variable        | Type             | What it returns                                          |
| ---------------------- | ---------------- | -------------------------------------------------------- |
| **Clicked Item**       | Record (SObject) | The full Salesforce record of the item the user clicked. |
| **Clicked Item Value** | Text (String)    | The value of the clicked item.                           |

> **Example:** A user clicks on a product card in the Visual Picker to see more details before selecting it. Use **Clicked Item** to display a detail panel.

### Component Metadata

| Output variable     | Type    | What it returns                                                                                                                              |
| ------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| **Number of Items** | Integer | The total number of items currently loaded in the Visual Picker. Useful for displaying a count or making decisions when the picker is empty. |

***

## Styling

The Styles panel lets you customize the look and feel of your Visual Picker to match your design preferences. Here are the key styling options you can adjust:

### **Layout and Spacing**

* **Margin:** Control the space around the Visual Picker.
* **Size:** Choose the overall size (small, medium, or large) to fit your content best.

### **Text and Typography**

* **Header:** Adjust the color, font size, style, and weight of the label text.
* **Figure Title & Description:** Customize the appearance of the figure title and description text.
* **Title & Description:** Customize the appearance of the main title and description text, including an option to limit the number of lines displayed for the description (line clamp).
* **Tag:** Control the font, border, and line height of any tags within the Visual Picker.

### **Visual Elements**

* **Avatar:** Choose how to align avatars within the picker (top, center, bottom).
* **Background:** Set the background colors for normal, hover, and selected states.
* **Border:** Customize the appearance of the border surrounding the Visual Picker items.

By experimenting with these options, you can create a Visual Picker that perfectly complements your application's design and enhances user experience.

## Examples

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FO9DMusLJ7EmJ1C3WLAss%2F2022-11-01_21-00-00.png?alt=media&#x26;token=28c3b03a-ed84-4618-ba7f-efa24d49facd" alt=""><figcaption></figcaption></figure>

{% @arcade/embed flowId="4oqeIsfSNhKS7GlT4liv" url="<https://app.arcade.software/share/4oqeIsfSNhKS7GlT4liv>" %}
