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
RyanJenkinsRyanJenkins 

Autofilling County from City or ZIP codes

Hi. I recently instituted a web-to-lead form on our website, and I received advice that asking for a visitor's ZIP code is a nice non-intrusive way of gathering useful, but still ambiguous, information about where they live. This, in turn, is useful for all kinds of segmenting, obviously.

 

So, now I have a database with some rather poor data quality: some records have just addresses with no ZIP, some have ZIPs without a city, barely any have a county entered, etc.

 

I'm wondering if there is a relatively simple way to harvest this kind of information from an address. In fact, I won't be greedy, I'll settle for determining county from a ZIP code, which seems like it would be the easiest – ZIPs are a standardized format, as opposed to city names or addresses. There are two paid apps in the app store (PostCode and AddressGrabber), but we are a nonprofit, so the cheaper we can get this done, the better.

 

I wonder if there is some way to write an S-Control that would harvest the city information with a process like this:

1) Enter a ZIP into MapQuest, by calling up this address: http://www.mapquest.com/maps?zipcode=[ZIP]

2) Get the source and harvest the title of the resulting URL by parsing this formula: "Map of [CITY, STATE] by MapQuest"

 

Can this be done with relatively a simple Javascript, built into an S-Control? And then where to go from there?

 

I have a very long formula field set up to assign zones (our segmentation scheme) from counties, but it is just one huge hand-coded switch/case syntax. An approach like that is completely impractical for something like ZIPs or Cities.

 

Thanks in advance.

Ryan 

ShikibuShikibu

I suggest that you purchase a zipcode database (they are inexpensive, but you need to update regularly).

 

Then create a custom object with the zipcode data, and use a trigger on entry of addresses that sets city, state, county.

 

The USPS also provides a webservice that offers these services.

ogomezogomez

Hi. Can you provide more detail about the custom object +trigger solution. Thanks

 

ShikibuShikibu

1. Create an object that contains the data that the zip codes vendor provides you.

 

2. Create a trigger for contact created or edited, and one for account as well.

 

3. Use the zip code to look up the city and county in the custom object, and fill in the field on the contact or account.