Inserting City and State Automatically into Microsoft Dynamics CRM

1. For CRM 2011 : Microsoft Dynamics CRM 2011: Lookup address by ZIP Code

2) Update of Latitude/Longitude fields using BingMaps services through SSIS Integration Toolkit

2. For CRM 4.0:

Update: Inserting City and State Automatically into Microsoft Dynamics CRM
by BenVollmer 7. May 2010 00:21

It is really hard to believe that I have been blogging for this long. And it is funny how things change. And some things stay the same. So about 4 years ago, I wrote a blog article on using Yahoo’s Web Services to get the City and State based upon a Zip Code Entry.

In talking with one of my co-workers about a demo she was doing, I recommended she look at it as a way to show how we can interface with external systems. Well guess what, Yahoo changed their API’s all around.

So now you need to get an application key for Yahoo and change your URL’s.  So if you want to use this code:

1. Visit

2. Create a Anonymous Project.

3. Get your Key

4. Insert your key in the first line of code below.

5. Place this on the OnChange Event for the Zip Code Field for either the contact or account entity.



var sUrl = YOUR APP ID HERE!!!;
sUrl += “&zip=” + crmForm.all.address1_postalcode.DataValue;
var oXmlHTTP = new ActiveXObject(“Msxml2.XMLHTTP”);
oXmlHTTP.Open(“GET”, sUrl, false);
var oXmlDoc = oXmlHTTP.responseXML;
crmForm.all.address1_line1.DataValue = oXmlDoc.selectSingleNode(“ResultSet/Result/Address”).text
crmForm.all.address1_city.DataValue = oXmlDoc.selectSingleNode(“ResultSet/Result/City”).text
crmForm.all.address1_stateorprovince.DataValue = oXmlDoc.selectSingleNode(“ResultSet/Result/State”).text
crmForm.all.address1_country.DataValue = oXmlDoc.selectSingleNode(“ResultSet/Result/


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: