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 https://developer.apps.yahoo.com/
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.
Enjoy!
Ben
var sUrl = http://local.yahooapis.com/MapsService/V1/geocode?appid=INSERT YOUR APP ID HERE!!!;
sUrl += "&zip=" + crmForm.all.address1_postalcode.DataValue;
var oXmlHTTP = new ActiveXObject("Msxml2.XMLHTTP");
oXmlHTTP.Open("GET", sUrl, false);
oXmlHTTP.Send();
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/Country").text