Overview
Field dependency in Salesforce is a declarative feature that controls the available values of one field (the dependent field) based on the value selected in another field (the controlling field). It’s commonly used with picklists and checkboxes to create a dynamic, context-aware UI that reduces user error and improves data quality.
Key Concepts
There are two roles in a field dependency:
- Controlling field: The field whose value drives which options appear (can be a picklist or a checkbox).
- Dependent field: The field whose available values change based on the controlling field (typically a picklist).
When to use field dependencies
Field dependencies are ideal for scenarios such as:
- Showing relevant sub-categories when a category is chosen.
- Displaying region/state options based on country selection.
- Hiding irrelevant picklist values to prevent invalid combinations.
How to create a field dependency (UI steps)
To create a field dependency in Setup (Classic or Lightning):
- Go to
Setup > Object Managerand open the relevant object (e.g., Account). - Select
Fields & Relationships, then clickField Dependencies(orNew>Field Dependency). - Choose the Controlling Field and the Dependent Field.
- Use the dependency matrix to map which dependent values are available for each controlling value.
- Save and test the behavior on a record page.
Example mapping (visualized as JSON)
{
"ControllingField": "Country",
"DependentField": "State",
"Mapping": {
"USA": ["California","Texas","New York"],
"Canada": ["Ontario","Quebec","British Columbia"],
"India": ["Maharashtra","Karnataka","Delhi"]
}
}
Limitations and considerations
- Dependent fields are typically picklists — the controlling field can be a picklist or a checkbox.
- Field dependencies are configuration-driven; they don’t require Apex or code changes for standard behavior.
- Complex UI behavior or conditional logic beyond picklist-value control may require record types, validation rules, Flow, or custom Lightning components.
- When using dependent picklists with record types, ensure the picklist values are available for the record type as well.
Testing and best practices
Test field dependencies in a sandbox or developer org first. Best practices include:
- Keep mappings simple and maintainable — avoid overly complex, nested dependencies.
- Document mappings so admins and developers understand the allowed combinations.
- Combine with validation rules or Flows if you need server-side enforcement or automation.
- Consider the mobile experience — Lightning pages and mobile app behavior should be validated.
Alternatives
If field dependencies can’t model the required behavior, consider:
- Record types to present different page layouts and picklist value sets.
- Validation rules to enforce combinations that are not expressible in the dependency matrix.
- Salesforce Flow or Apex to apply conditional logic and automate updates.
Summary
Field dependency is a powerful, declarative way to control picklist choices based on another field’s value. It improves data quality and the user experience with little to no custom code. When requirements exceed the dependency matrix, combine it with record types, validation rules, Flow, or custom components for a complete solution.





Leave a Reply