A common requirement to integrate maps in to Microsoft CRM to see the location of a CRM entity has been a very common requirement. Recently I had to do this for one of my customers so I thought why not share the code with all the CRM enthusiasts out there.
The procedure is very simple.
- Create a application that uses the Google Maps API (I had to use Google because Bing maps was not for Cambodia)
- Pass the parameter values to the map from CRM
There are plenty of resources and code samples on the net for this. But the best one I got from my friend Andriy. He is a Microsoft CRM MVP and one guy who is the best of what he do (that is CRM of course). You can download the full code from Andriy’s blog and I have added the compiled code that I used. To go to Andriy’s blog post click this link - http://a33ik.blogspot.com/2010/06/intergration-google-maps-v3-into.html
Ok so how do we do it,
- Download the compiled map htm file and copy it in to the ISV folder in the CRM website
- Add an frame in to CRM and name it map or what you like
- Write the coding on the on-load event in the form.
crmForm.all.tab2Tab.onclick = function()
{
if (crmForm.all.new_project_cityid.DataValue[0].name != null
&& crmForm.all.new_projectstreet1.DataValue != null )
{
var oldurl = crmForm.all.new_project_cityid.DataValue[0].name + ","+ crmForm.all.new_projectstreet1.DataValue;
}
if (oldurl != "")
{
var url = "/ISV/gmap/mapintegration.html?address=" + oldurl;
crmForm.all.IFRAME_map.src = url;
}
}
Just to clarify, my tab number is 2. My Iframe name is IFRAME_Map. The challenge I found is that in Cambodia it really didn’t work when I use more than 2 values. So what I went for basically is the city and the street number. Example: Phnom Penh, St 271
Finally I added a little additional modification since Andriy’s original code use only text box but my customer wanted a lookup. So my city is in a lookup and the street is in a text box. All you have to do for that is use the following code to pass the data value
1: crmForm.all.new_project_cityid.DataValue[0].name
Great that’s all. You can easily see where your place in the map is now

A very special thanks to CRM Guru Andiry Butenko.