Monday, April 27, 2009

Maps Integration for Dynamics CRM 4

There has often been a need especially when you have Sales rep requiring to visit the clients on-site to be able to get the directions to the customer location. Google Maps, Live Maps, Mappoint are some of the services that you can use to incorporate this feature in CRM. While Mappoint is a paid service, the other two are free services and can be used to plot the customer address on the map.

One of the important pre-requisites while plotting a customer address would be to geo-code (get the latitude and longitude) the addresses. It is using these geo-coding that the addresses are plotted on Map. Since a customer’s address would not change often, it is a good idea to write a workflow that will geo-code the customer addresses each time a new customer is created or its address updated.

The following webservice from Google can be used for geo-coding addresses.

Once the addresses are geo-coded, we can add a tab on CRM account/contact form and display the customer address in a map. The map will place a pushpin at the customer location.

This can further be extended to get the Route and Directions to the customer location from a base location.

Using Live Maps it can be done using the following code

locations = new Array(‘addr1’,’addr2’);

//Make an object of RouteOptions
var options = new VERouteOptions;

// Draw the route
options.DrawRoute = true;

// So the map doesn't change:
options.SetBestMapView = true;

// Call this function when map route is determined:
//options.RouteCallback = ShowTurns;

// Show as miles
options.DistanceUnit = VERouteDistanceUnit.Mile;

// Show the disambiguation dialog
options.ShowDisambiguation = true;

//Show the directions on the map
map.GetDirections(locations, options);";

This will show a map with the route marked starting from the start point to the end location.

Another use of integrating maps would be to search of location within a given distance range. So you are visiting a customer in “Redmond” and would want to find out the other customers that are in and around this location so that you could schedule an appointment with them. Or it could be used for schedule service requests for a sales rep. If a salesrep was already scheduled for a call in Redmond area and there was another ticket raised for that area it could be handed to the same sales rep for servicing.

This could be done by finding the distance between the base location and other customer addresses and plotting the customers that fall within the requested distance on the map. One pushpin will be placed on the map for each customer address that is being shown in the map.

There is so much you can do with Maps :) And it is pretty easy to as its shown above and requires a bit SDK skills and programming knowledge. The web is full of details as to how to use various maps functionality to achieve the same. We at Inogic were debating whether to come up with an add-on for Live Maps integration at all or just leave it for you people to figure out on your after giving you the above methodology.

1 comment:

  1. Thanks for the article and for the code. However, I just wanted to point out that what you've shown is not free under Google's or Microsoft's terms of use for their mapping services. The catch is that their services are free if you're using them on a publicly accessible web site. For apps like Dynamics CRM which are only accessible to employees (and maybe some partners, etc) you would need to license it through Microsoft or Google.