Salesforce flow is great alternative for Visualforce pages used by admin. I have written, multiple blog post on Salesforce flow already and in this post we will discuss how we can create dependent picklist in Flow.
If you are already using flow, might know that creating dependent picklist is not supported yet. However we will be taking help of Custom Metadata types to create same behaviour in Salesforce flow.
Why Custom Metadata Type ?
In Summer 15, Salesforce has introduced Custom metadata types on platform. We can use Custom metadata types in place of List Custom settings because of one important benefit “deployment”. Custom Setting and Custom label has always been best friend of developers and admin for a long time to make Salesforce applications more configurable and dynamic. When I say “deployment”, whenever we deploy custom setting between sandboxes and production or distribute packages, records inside custom settings are not moved. We need to take help of API’s or Dataloader to load initial data in Custom setting after deployment. However with Custom metadata type , records are also moved. Setting up Custom metadata type is fairly simple and almost equivalent to List custom setting.
In this blog, we will create dependent picklist of three level. “Country” will be selected and on basis of it, “State” would be displayed and on basis of “state”, “city” would be displayed. Dependent picklists is displayed on same page in standard user interface however in Flow, it would not be possible. For each dependent picklist, we need to have one screen and therefore in our example, we will have total three screens.
First we need to setup Custom Metadata type which will have information needed to create dependency between fields. Navigate to “Setup | Build | Develop | Custom Metadata Types | New Custom Metadata Type”. For this example, we will name custom metadata type as “Dependent Picklist” with following custom fields:
- Object Name for Dependent Picklist (Created on which object)
- Controlling field API Name (API name of controlling field)
- Controlling field Value (Value which will control values in dependent field)
- Dependent field API Name (API name of dependent field)
- Dependent field value (Value which should be displayed on basis of value on controlling field)
Below image shows structure of Custom Metadata type created for this example Continue reading “Dependent picklist in Salesforce flow using Custom Metadata type – Video”