# How do Dependent Picklists guide user data entry by filtering options based on controlling field values?

**Topic:** Admin · **Difficulty:** Medium · **Tags:** Admin, Dependent Picklists, Field Dependencies

Read it on the site: https://www.forcechallenges.com/interview-questions/how-do-dependent-picklists-guide-user-data-entry-by-filtering-options-based-on-controlling-field-values

## Answer

**Basics:** It prevents impossible combinations such as Country = India with State = Texas. The controlling field is a standard or custom picklist or checkbox; the dependent field must be a custom picklist (standard picklists cannot be dependent fields, though many can be controlling).

**How it works:**
1. Setup > Object Manager > object > Fields & Relationships > Field Dependencies > New.
2. Select Controlling Field and Dependent Field.
3. In the matrix, select values of the dependent field and click Include Values for each controlling value; Preview to test.
4. Add both fields to the page layout (or record page) so users can interact.
5. For record types, ensure the chosen values are also available in the record type picklist assignments.

**Advanced / deep dive:** The dependent field is disabled until the controlling field has a value. A dependent picklist can also be a controlling field for another, so you can chain Country, State, City, but keep depth small. The controlling field is limited in values (around 300; verify) and dependent fields store a bitmap-style "valid for" definition. Global Value Sets can supply values to multiple fields consistently. Dependency enforcement is a UI behavior; saving via API or Apex does not always reject invalid combinations (especially when the field is not restricted), so add a validation rule or trigger check when data integrity matters. Changing the controlling value in the UI clears the dependent value, but integrations may leave stale combinations. In LWC, `getPicklistValues` from `lightning/uiObjectInfoApi` returns `controllerValues` and `validFor` indexes for the dependent field, so you can build custom dependent controls. Dynamic Forms and Flow Screen picklists also honor dependencies. State and Country picklists (standard address) are a separate feature that handles ISO codes.

**Code / config example:**
```javascript
import { LightningElement, wire } from 'lwc';
import { getPicklistValues } from 'lightning/uiObjectInfoApi';
import STATE_FIELD from '@salesforce/schema/Account.State__c';

export default class StatePicker extends LightningElement {
    controllerKey; // set from the controlling field's selected value index
    @wire(getPicklistValues, { recordTypeId: '012000000000000AAA', fieldApiName: STATE_FIELD })
    picklist;

    get options() {
        const d = this.picklist?.data;
        if (!d) return [];
        // validFor holds indexes of controlling values for which this value is valid
        return d.values.filter(v => v.validFor.includes(this.controllerKey));
    }
}
```

**Hidden gotchas & must-remember points:**
- Dependencies are not guaranteed enforcement through API; add validation for critical data.
- Controlling fields can be checkboxes, and dependent fields must be custom picklists.
- Removing a value used in dependencies needs matrix cleanup.
- Record types filter values further; a value must be both dependent-valid and record-type-valid.
- Reports show actual stored values, even invalid combos.
- Master record type ID `012000000000000AAA` is used when no record types exist.

**Best practice:** Design the value matrix first, keep chains shallow, and back it with a validation rule if data is loaded outside the UI.

---
Source: ForceChallenges · last updated 2026-11-02
