In my previous post, I showed you a simple way to integrate Bing Maps with Microsoft Dynamics CRM 4.0 using iFrames and address data on a custom Dynamics CRM form. In this post, I will show you how to display a map for an Account record in a custom ASPX page.
The idea behind this integration is to open an Account and click on a custom button on the Account form to pop-up a custom ASPX page to display the map. Firstly, we need to add a custom button to the Account form. To do this, export the ISV Config file and locate the following tag:
We want to add the following code beneath this tag.
Save the file and import it back into Microsoft Dynamics CRM. Refresh the browser for the changes to take effect. Note – if the button still doesn’t appear, make sure that the Custom Menu and Toolbars section has been configured correctly in the Customizations tab under System Settings.
The showMap function calls the VEMap constructor inside the referenced script. The parameter passed to this function is the id of the <div> tag that you wish to display the map inside. Do not create a <div> tag for the map. We will do this inside the C# code-behind.
Now we need to add some code to the view-map.aspx.cs file. Here’s what the code in the Page_Load handler looks like.
After you have deployed the custom aspx page, we’re ready to test and see how it works. Create a new Account record and specify the address details.
Next, click on the custom “View Map” button on the Account form toolbar.
Here is the resulting map.
And that’s all there is to it - another nice way to integrate Bing Maps with Microsoft Dynamics CRM 4.0. Stay tuned for future posts where I will show you some more cool ways to integrate the two systems.