In my past posts I have already shown you how to display a map inside a Microsoft Dynamics CRM 4.0 iFrame as well as a custom ASPX page using the Bing Maps service. Now, I will merge these two techniques together and display the driving directions between two locations on a custom ASPX page which will be hosted within an iFrame and displayed on a Dynamics CRM form. But that’s not all. I will also pull the total distance and estimated driving time between the two locations from the custom ASPX page, and store them inside CRM form fields.
This integration would be highly useful in a number of situations. My first post described a local transport company who are currently struggling to constantly switch between their internal system and Google Maps in order to retrieve distance and time information for bus charters. Having this information automatically retrieved for them would greatly save time.
You might be part of an organization that provides on-site services which require a “call-out” fee. Another benefit that this functionality provides is greater distance and time accuracy, which can then be fed through to a quote resulting in more accurate cost estimates.
How it Works
Firstly, I’ve created an iFrame inside a custom entity called Charter Request. The reason we need to display the map inside an iFrame is because Bing Maps requires a map image to be present in order to grab the total distance and time information. We want to use the following settings for the iFrame:
When we grab the total distance and estimated time information from the route, we can pass the information back into Dynamics CRM by using the following code:
Let’s take a look at this functionality in action. Here I have created the new record in Dynamics CRM to define the trip details.
After pressing Save, the form reloads and displays the map inside the iFrame and also fills in the Total Distance and Estimated Time attributes.
The map is fully interactive and allows you to zoom in and out or pan to different areas of the map. Pretty cool if I may say so myself! If you would like to receive more information about this integration between Microsoft Dynamics CRM 4.0 and Bing Maps, please contact us. You can also find out more by visiting the Bing Maps Developer Centre.