How-to look up zip code for city & state; Visualforce example


Doing a zip code lookup to get city and state is such a common task  and yet the Salesforce platform does not natively support this.  This simple function benefits both the user by making entering addresses easier and the Salesforce administrator by ensuring data cleanliness and uniformity.  Although a number of App-exchange packages support this functionality the ones I browsed are very fully featured and way overkill for a simple zip code lookup.  So, I went looking for a free zip code lookup service I could use.  There are a number of sources – even the US Postal Service does this!  I used because it’s very straightforward to implement as we shall see.

I created a VisualForce page for the UI and a matching Apex custom controller to implement the REST callout and supporting logic.  Below is a screenshot of the VF page.  Users enter their 5 digit zip code and click Lookup!  The bottom half then displays the…

View original post 800 more words