# Data Fields

Data fields are advanced, structured input types that allow you to integrate external datasets directly into Fairmarkit’s intake or RFx's. These fields streamline selection from complex lists (such as cost centers, GL accounts, preferred supplier lists, etc.), and support dynamic filtering and intelligent previews to guide users toward the right choices.

***

### When to use Data Fields

Use data fields when you want to:

* Allow users to select from a **centralized, curated list** of entries (e.g., cost centers).
* **Enforce consistency** across submissions by referencing a single source of truth.
* **Filter options dynamically** based on metadata like location, category, or business unit.
* Provide **structured previews** that help users make informed selections without confusion.

***

### Key Features

#### Slug Identifier

Each data field links to a specific dataset using a **slug** — a unique identifier like `preferred-supplier` or `approved-contracts`. This tells Fairmarkit which dataset to reference.

#### Preview Fields

You can define which fields are shown in the dropdown or selection view — such as `name`, `ID`, or `supplier type` — to help users differentiate similar entries.

> Example: Previewing “Vendor Name” and “Contract Expiration Date” side-by-side.

#### Filter Tags

Use metadata tags to limit what users see in the dropdown based on form context.

> Example: Filter a list of vendors by country (`US`) or contract type (`SOW`) using tag-based rules.

#### Fieldset Format

Data fields are organized using a **fieldset layout**, which lets you embed nested objects like `{ id: string, name: string }` as a single, structured input.

***

### Configuration Options

| Property              | Description                                                                   |
| --------------------- | ----------------------------------------------------------------------------- |
| `datafieldSlug`       | The reference key for the external dataset                                    |
| `datafieldPreview`    | A list of fields to show in the dropdown preview (e.g., `["name", "status"]`) |
| `datafieldFilterTags` | A list of filtering rules based on form values (e.g., `[{ country: "US" }]`)  |
| `fieldsetVariant`     | Set to `"datafield"` to activate advanced dataset behavior                    |
| `stored`              | Indicates whether the selected value should be persisted                      |

***

### Example Use Case

> You want requestors to select from a pre-approved list of **consulting vendors** relevant only to the U.S.

Configure the data field as:

* `Slug`: `approved-vendors`
* `Preview Fields`: `["name", "service_area"]`
* `Filter Tags`: `[{ country: "US" }]`

This results in a dropdown that shows only U.S.-based consulting vendors, with clear preview labels for each.

***

### Best Practices

* **Keep datasets clean and curated** — data fields reflect exactly what’s in the source list.
* **Use preview fields sparingly** — too many can overwhelm the user.
* **Combine with conditional logic** to display the field only when relevant (e.g., if “category” = “IT”).

***

### Summary

| Feature               | Benefit                                        |
| --------------------- | ---------------------------------------------- |
| External dataset link | Pulls in real-time structured values           |
| Preview configuration | Helps users choose the right entry easily      |
| Filter by tags        | Limits entries based on form context           |
| Nested object support | Captures structured metadata in a single field |
| Works with conditions | Enables dynamic, responsive form behavior      |
