Pour Some Sugar On Me...
It's taken a while, but I have finally got round to finishing my MapPoint integration code for CRM 3.0. There's a whole bunch of things you can do with Microsoft MapPoint, but the most obvious is to display a location map based upon the address fields of an Account or Contact record.
I took the easy options of using an IFRAME and building a fairly straightforward ASP.NET page to handle the heavy lifting. I chose to display the map automatically, rather than having to click a button on a form, and the result is shown below.
In order to use the solutions you need to sign up for a MapPoint developer's account as detailed in my earlier post here, then you need to get the Visual Studio 2003 project files which I have uploaded as a .ZIP file here.
- Customise the Account entity, and edit the main application form. Add a new tab called "MapPoint" to the form, then add a new section to the tab called "Map". In order for the map to use up all the available space on the form, I chose to hide the "Map" section.
- Create an IFRAME in the new section and set the name to "IFRAME_MapPoint". Set the URL to "about:blank" which will ensure that in the event of any unexpected errors, the map will just display a blank page.
- To ensure that the map displays correctly, change the following parameters in the IFRAME Formatting tab:
- Next, edit the form "OnLoad" event and copy the contents of the Account_OnLoad.js file that is included as part of the Visual Studio 2003 project. This script passes the address fields (Address Line 1, Address Line 2 etc) from the form to the MapPoint.aspx web page. Because there is no address information when you first create an Account, I've included some logic to prevent the MapPoint.aspx from being called unnecessarily.
- Don't forget to edit the URL in the OnLoad event to point to your own CRM Server, e.g http://crmserver:5555
- Now you need to set up the web site to host the MapPoint.aspx page. I chose to create a new sub-folder called MapPoint in my CRM Web Server <System Drive>:\Inetpub\wwwroot\MapPoint - Note: The CRM web site folder location may vary based on your original CRM installation options.
- Using IIS Manager, right click the MapPoint folder in the CRM web site, select properties, and click the "Create" button to convert the folder into a Web Application. This is important as we are using our own web.config file to store various application parameters.
- Finally, edit the web.config file that is included as part of the Visual Studio 2003 project. and change the following application parameters to your own MapPoint web service User Name and Password:
<add key="MapPointUserName" value="UserName" />
<add key="MapPointPassword" value="Password" />
You'll see some other parameters here which control the size of the map displayed as well as the scale of the map. You can change these to meet your specific needs.
- Repeat this process for other entities that have address fields, such as Contacts and Leads.
That's all there is to it. Once you have published the customisations, this should work a treat. I will cover the actual code at a later date, but I have tried to perform a sensible amount of error checking so that any failures are handled gracefully.
This posting is provided "AS IS" with no warranties, and confers no rights.