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
spectrawolfspectrawolf 

Update city and state fields with zip code

Is there a way to auto-populate the city and state fields based on the zip code entered?
Best Answer chosen by Admin (Salesforce Developers) 
bikla78bikla78

You'll have to first purchase a list from USPS or a web resource for all zip codes in the United States and their states.  You can either populate this data into a <list> and <map> and use an before insert trigger to update the fields when you create an account. I'd also place a validation rule in the zip field to only accept xxxxx amount of chracters.

 

If not, you can also populate this data into a text file and use a visual force page to reference the text file to update the fields.

 

hope this helps

 

All Answers

bikla78bikla78

You'll have to first purchase a list from USPS or a web resource for all zip codes in the United States and their states.  You can either populate this data into a <list> and <map> and use an before insert trigger to update the fields when you create an account. I'd also place a validation rule in the zip field to only accept xxxxx amount of chracters.

 

If not, you can also populate this data into a text file and use a visual force page to reference the text file to update the fields.

 

hope this helps

 

This was selected as the best answer
spectrawolfspectrawolf
Thanks!