In Salesforce, field dependencies are the filters that let users alter a picklist's items based on the value of a different field.
Field dependency means, controlling a field’s value based on the other field.
For instance, there are two fields labelled State & Country. When I choose a country, I only want the states associated with that particular country to be displayed.
We have to learn about two fields in Field Dependencies. They are:
- Controlling Field
- Dependent Field
Don't forget to check out: Access sObject's (Salesforce Object Type) Fields and Its Record | Apex Developer Guide
Controlling Field - A controlling field is one that determines which values are available in one or more related dependent fields.
Dependent Field - A dependent field shows values according to the value chosen.
- Custom picklists can be both Controlling and dependent fields.
- The standard picklists field can only be used for controlling.
- Default values can be set for the controlling field.
- We cannot set default values for the dependent picklist.
- Multi Select picklists can be dependent.
- Controlling fields must be added to page layouts.
- In the controlling field, we can add up to 300 values.
Some More Points About Dependent Fields
- The value selected in the controlling field affects the values available in the dependent field.
- A dependent field works in conjunction with a controlling field to filter its values.
- We can define custom picklist fields as controlling or dependent fields.
- The standard picklist field must be controlling fields. We cannot define standard picklist fields as dependent fields.
- We can define default values for controlling the field. But we cannot define default fields for dependent fields.
- We cannot define a multi-select picklist as controlling.
- We can define the checkbox as a controlling field only.
Check out another amazing blog by Sejal here: Learn How to Access Page Layout in Salesforce | Help Guide
To Create a Field Dependency:
Step 1 - Go to the setup menu and select the object you want to create field dependency.
Step 2 - Click on the field dependency button & select controlling and dependent fields. See the below screen for reference.
Step 3 - Select dependent fields under controlling fields by pressing the continue button. click Include, and then click Save. for more information, see the screen below.
Field dependency is now created. To verify this, enter the USA in the Country form. When you pick States, you will only see states that are part of the USA (Alabama, Alaska, Delaware, and Florida, as defined above).