function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
alexander yurpolskyalexander yurpolsky 

Building a complex address field (street-list based on city-list)

Hello,

Not sure how to implement my solution and would be happy to get your help.

So basically I have two Excel files.
The first is called Cities - there are two fields City-id and City-Name.
The second is called Streets - there are three fields City-id, street-id and street name.

The situation should be this:
First - User selects a city from a city-list.
Second - The user selects a street from street-list that related to the city he selected from a city-list

So in the street list, I need to show only the streets that are related to the city he chose.

I understand that I need to build two new objects here. Because using the pickup list will not help here. I'd love to get tips and ideas on how to implement it right.



 
Best Answer chosen by alexander yurpolsky
Alain CabonAlain Cabon
Hi,
  1. Global Picklists/Standard Picklists/Dependent Picklists (declarative): Up to 1,000 values https://help.salesforce.com/articleView?id=picklist_limitations.htm&type=5      https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_quick_start_dependent_picklists.htm
  2. Dynamic Picklists (programmatic): using <lightning:select> or <apex:selectList>
  3. Custom settings/Custom metadata (sometimes used instead of standard picklists):  http://force-salesforce.blogspot.fr/2012/06/creating-dependant-pickist-in.html     https://github.com/jbpringuey/SFDCConfig    https://developer.salesforce.com/blogs/engineering/2015/05/how-to-use-custom-metadata-types.html
No many responses for an equivalent question: https://salesforce.stackexchange.com/questions/150807/picklist-or-custom-metadata-or-custom-object-or-else

Lex: <lightning:select>
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_lightning_select.htm (https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_lightning_select.htm?search_text=option)
Create Dynamic Picklists for Your Custom Components
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/components_config_for_app_builder_dynamic_picklists.htm

Visualforce page: a common very used technique with <apex:actionSupport event="onchange" reRender="a"/>
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_selectList.htm

Dependent picklist using Apex in Salesforce: state > cities
http://www.infallibletechie.com/2012/10/dependent-picklist-using-apex-in.html

Finally, the most seen solution is the last example of code (state > cities) (easy to understand and to implement) when you cannot use the declarative way.