Field Dependency in Salesforce

Field Dependency In Salesforce
Field Dependency In Salesforce

Field Dependency in Salesforce is a kind of filter that allows users to change the values in the picklist based on the values selected in the other field.

Example: There are 2 fields Country & State. We have to display all the States of the country which are selected in the Country field. So here one field is dependent on the other field.

In Field Dependencies there are 2 fields:

  1. Controlling Field: Controlling field in Salesforce is the field that controls the value in the correspondent dependent field.
  2. Dependent Field: Dependent field in Salesforce is the field that shows values based on the values selected on the controlling field.

Important points about Field Dependency

  1. The value selected in the controlling field affects the value available in the dependent field.
  2. A standard picklist field can only be a controlling field, it can not be a dependent field.
  3. Custom picklists can be both a controlling and dependent field.
  4. We can not define multiple-picklist as a controlling field.
  5. We can define a default value for the controlling field, but can not define a default value for the dependent field.
  6. Controlling must be added to the page layout.
  7. The checkbox can be defined as a controlling field only.

Steps to Create Field Dependency

Before creating field dependency, we must have 2 fields, the first field act as a Controlling field, and the other activities as a Depending field.

In our example, I am using Country and State fields to create field dependency.

Step 1: Create Country and State Picklist Field

Country Field and it’s values

Country Field
Country Field

We have to add the values in this picklist, I have added limited values for the demo purpose.

Country List Values
Country List Values

State Field and its values

State as a Dependent field
State as a Dependent field

We need all the associated values of country in this field.

State values list

Step 2: Create Dependent Field

For creating Dependent field, we first need to move the Fields & Relationship page and click on Field Dependencies button.

A field dependency window will open, click New button on this window.

Create New Field Dependency

Now, we need to choose which field is controlling field and which is dependent field. In our example, we are using country as a controlling field and State as dependent field, So we need to chose these field in the respective options. Then click on Continue.

Now we have to map the countries with there states.

Mapping-the-dependent-fields
Mapping-the-dependent-fields

Select the States which are belong to the Countries.

Now, click on Include Value button and it will automatically include all the selected values in that controlling field value.

Similarly, you need to select the values for all the controlling fields.

After mapping the values in fields, click on save button. Your dependent field is created successfully.

Now let’s test the dependent field. Add Country and State field on page layout and try to create new record.

Step 3: Test the Controlling and Dependent Field

For testing the functionality, we need to add the Controlling Field(Country) and Dependent Field(State) on the page layout.

State field is showing states which belongs to Argentina
Controlling-field-in-Salesforce-1
States field is showing only fields which belons to Australia.

If you observe the above images, you will field State field is showing different results for the different country, so this is only possible with the help of Field dependency in Salesforce.

I hope you like this tutorial and if you want any help let me know in the comment section.

Stay tuned, there is way more to come! follow me on Youtube, Instagram, Twitter. So you don’t miss out on all future Articles and Video tutorials.

. . .

I am delighted that you read my article! If you have any suggestions do let me know! I’d love to hear from you. ????

About the Author

Shubham Agarwal is a passionate and technical-driven professional with 5+ years of experience in multiple domains like Salesforce, and iOS Mobile Application Development. He also provides training in both domains, So if you looking for someone to provide you with a basic to advance understanding of any of the domains feel free to contact him

Leave a Reply