Hi folks, Hope you are doing well. In this session, we are going to see Field Dependencies in Salesforce. Field Dependencies allows us to filter the values of picklist field based on the other field.
After completing this tutorial you are going to understand:
- What is field Dependencies in Salesforce?
- How to Create Field Dependencies in Salesforce?
What you’ll do?
- Create Field Dependencies using Country, State example.
What is Field Dependencies?
Field Dependencies allows us to filter the values of picklist field based on the other field. In field Dependencies, one field is controlling field and the second one is dependent field The value of the dependent field depends on the selection of the controlling field. The best example of Field dependencies is that instead of displaying all the state values in the picklist we can filter these values based on the country. This is an excellent style to choose the correct quickly and in a user-friendly way.
The values for picklist could be defined as controlling fields and dependent fields as shown below:
A Controlling field is one which is used to filter the values in one or more corresponding dependent field.
It is used to display filter values based on the selected value in the controlling field
If I talk about the Country State example, the controlling field would be Country and State would be a Dependent field.
Some interesting points about Dependent field:
- Value change in the controlling field affects the value available in the dependent field.
- A dependent field works in conjunction with a controlling field to filter its values.
- A Custom picklist can be defined as Controlling field or Dependent field.
- A Standard picklist can be defined as only Controlling field. We can not define a Standard picklist as a dependent field.
- We can set a default value only for controlling field, not for a dependent field.
- A multi-select picklist can be defined as an only dependent field, not as a controlling field.
- We can define a checkbox as controlling field, not the controlling field.
Create Field Dependencies in Salesforce:
Login Salesforce to create Field Dependencies in Salesforce for Contact. Goto Contact and View Fields and choose Field Dependencies.
- As there are no Field dependencies in the object click on the New button.
- Now select the controlling field and Dependent field. Here we have selected controlling field as Country and dependent field as State.
Click on continue and select dependent fields under controlling fields. click on include & then Save. see the below screen for reference.
Click on the Save button. Field dependency is created now. To test this go to Country field and select the USA, In states, you will get only States related to USA ( Alabama, Alaska) as defined above.
- Validation Rule in Salesforce.
- Process Builder in Salesforce.
- Batch Apex in Salesforce.
- Map Class in Apex Salesforce.
I hope you would love this session. Please don’t hesitate to comment for any technical help. Your feedback and Comments are valuable to me.