Skip to main content

How to create dependent picklist in salesforce

Dependant Picklists are those the values of which depend on the chosen value of another field.

Lemme tell you with a simple example.

Let's say there are 2 Picklist fields -- Country and States. You might of come across such scenarios where if you choose a value , let's say India in the Country field and then move to the State field to choose the State, you would only see the states that belong to the chosen value- India . So you would not find states in the State field that belong to any other country .

Here the value of the State field is dependent on the Country field. Here State field is called the Dependent field.

How to create dependent picklist in salesforce


Let's do it here :

At first create 2 custom Picklist fields , following the summarized steps here :  Setup |[ Customize | Create ] | choose the object where you would want to create the Picklist | New | and then follow the steps to create the picklist.

Now, after creating Country and the State Picklists, just go back to the Custom Object Definition Detail page and then click on Field Dependencies, that would be there in the Custom Fields and Relationships section .

Custom Fields & Relationships


Then click on New to create a new field dependency

Choose the Controlling and then Dependent Fields

 

The Controlling Field should be Country and the Dependent Field should be the State. This ensures that the values of the State Field are dependent on the Country Field.

Then click on Continue

Here mark the appropriate States to their respective countries by selecting the values in the respective boxes and then clicking on Include Values.

 Country:  India  China  USA  Germany  Russia 
 State:  Andhra Pradesh  Andhra Pradesh  Andhra Pradesh  Andhra Pradesh  Andhra Pradesh 
 Arunachal Pradesh  Arunachal Pradesh  Arunachal Pradesh  Arunachal Pradesh  Arunachal Pradesh 
 Assam  Assam  Assam  Assam  Assam 
 Gujarat  Gujarat  Gujarat  Gujarat  Gujarat 
 Karnataka  Karnataka  Karnataka  Karnataka  Karnataka 
 Madhya Pradesh  Madhya Pradesh  Madhya Pradesh  Madhya Pradesh  Madhya Pradesh 
 Maharashtra  Maharashtra  Maharashtra  Maharashtra  Maharashtra 
 Orissa  Orissa  Orissa  Orissa  Orissa 
 Tamil Nadu  Tamil Nadu  Tamil Nadu  Tamil Nadu  Tamil Nadu 
 Uttar Pradesh  Uttar Pradesh  Uttar Pradesh  Uttar Pradesh  Uttar Pradesh 
 Alabama  Alabama  Alabama  Alabama  Alabama 
 Alaska  Alaska  Alaska  Alaska  Alaska 
 Arizona  Arizona  Arizona  Arizona  Arizona 
 Arkansas  Arkansas  Arkansas  Arkansas  Arkansas 
 California  California  California  California  California 
 Colorado  Colorado  Colorado  Colorado  Colorado 

Click on Save to save the changes.

We have now created a field dependency between 2 Picklist fields - Country and State.

Now go back to the object where you have created the picklist and check if you are able to see Albama in the State Picklist when you have chosen India in the Country picklist.


Dependent Fields

Country
State

Depends on "Country"




Comments

Post a Comment

Popular posts from this blog

How to create a validation rule in Salesforce

Validation rule is a filter or a criteria that validates the data that is pushed into an application and verifies if the data that has been entered is in accordance to the set standards. Example : Let's say, there is a field that is used to enter the Age of a Student. But per the organization rule, no student should be allowed to join the course if the age is not more than 25 years. So here you may write a validation rule saying that the Age field should not be more than 25. In case the age entered is more than 25, then the record is not allowed to be saved. You would see an error when you enter the age more than 25. Let me give you another example.  Say that there's a field to enter the Product code. And per the rule of the organization, the Product code should always start with PR. In case you enter any code other than the one that begins with PR, you would encounter an error. The benefits of Validation rules is that you can improve the quality of the data that is go...