Simple Integration between Bing Maps and Microsoft Dynamics CRM 4.0

Roshan Mehta, 05 August 2010

I have recently been speaking with a representative of a local transport company providing bus charter services to various businesses and individuals in different parts of the country. The transport company currently uses a system which lacks the ability to accurately calculate travelling distances and time between two (or more) locations. System users are required to continuously switch between the internal system and online mapping facilities to enter data and retrieve information about each trip. This got me thinking about the possibilities of integrating Bing Maps with Dynamics CRM 4.0, and how this could greatly improve productivity and save time.

Bing Maps provides a rich mapping experience for users all over the world. There are various API’s which allow you to include a mapping facility within many types of applications, including Dynamics CRM 4.0. Consider this as the first post in a series on how to perform such integration between the two systems.

The first (and probably the most easiest) way to integrate Bing Maps with Microsoft Dynamics CRM 4.0 is to simply use an iFrame to display the Bing Map from within the entity form. We will need to pass the address information as part of the URL so that Bing Maps knows the route and driving directions to display.

Firstly, I created a new entity called Charter Request with two address sections. Each section contains the relevant information that needs to be passed to Bing Maps in order to display the correct mapping information.

Next, we need to create the iFrame to display the map. Create a new section on the entity form called Map and add an iFrame to it. Ensure to use the following settings for the iFrame.

To pass the trip details to Bing Maps, use the following JavaScript on the forms onLoad event.

var fromStreet = crmForm.all.mag_fromstreet.DataValue;

var fromSuburb = crmForm.all.mag_fromsuburb.DataValue;

var fromCity = crmForm.all.mag_fromcity.DataValue;

var fromPostalCode = crmForm.all.mag_frompostalcode.DataValue;


var fromAddress = fromStreet + " " + fromSuburb + " " + fromCity + " " + fromPostalCode;


var toStreet = crmForm.all.mag_tostreet.DataValue;

var toSuburb = crmForm.all.mag_tosuburb.DataValue;

var toCity = crmForm.all.mag_tocity.DataValue;

var toPostalCode = crmForm.all.mag_topostalcode.DataValue;


var toAddress = toStreet + " " + toSuburb + " " + toCity + " " + toPostalCode;


if (fromAddress != null && fromAddress != "" && toAddress != null && toAddress != "") {

    var mapUrl = "" + fromAddress + "~adr." + toAddress;


    crmForm.all.IFRAME_map.src = mapUrl;


Once the record is saved and the form reloads, the map image and driving directions are displayed within the iFrame.

This is a simple way to integrate Dynamics CRM 4.0 with Bing Maps. Stay tuned for my next blog where I will show you how to improve the mapping functionality in Dynamics CRM 4.0.