Duane Napier's Blog

Microsoft Dynamics CRM

  • Follow Duane Napier's Blog on WordPress.com

Posts Tagged ‘Bing Maps’

Adding Bing Maps to CRM 2011

Posted by duanenapier on December 31, 2012

When I give presentations to companies on Microsoft Dynamics CRM I am often asked if the product has any map integration for a salesperson’s use. This article will step you through the process to integrate Bing Maps.

Many times there is a need (or strong desire) to show an address on a map for a business or contact. Many companies would like to have their CRM system integrate with a mapping system without buying a 3rd party tool but aren’t sure how to do it. In short, it’s very easy and it only takes a small amount of time to set up an iFrame and Bing Maps inside Microsoft Dynamics CRM 2011.

What’s Required:

1) Create an iFrame on the Contact (or Account) form.
2) Create a JavaScript web resource (this is easy, don’t get overwhelmed just yet…)
3) Add an OnLoad event to the form.

Steps:
1) Customize the target form
a) Create an iFrame called Map (This newly created form field will show something like IFRAME_Map once you publish it).
b) Set the target to _blank & be sure to UNCHECK the “restrict cross-frame browsing”

BingMapiFrame

2) Create a Web Resource file that contains the form JavaScript. The JavaScript will be fired on the form OnLoad event which will take the address lines If you are using the Out Of the Box fields you can use the below syntax for your Web Resource file. CRM2011 supports older JavaScript so you may notice that I am using the older CRM 4.0 JavaScript syntax for the form fields.

function bingmap() {

var AddLine1 = crmForm.all.address1_line1.DataValue; var AddCity = crmForm.all.address1_city.DataValue; var AddState = crmForm.all.address1_stateorprovince.DataValue; var AccountZip = crmForm.all.address1_postalcode.DataValue;

if (AddLine1 != null )
{
var MapURL = ‘http://www.bing.com/maps/default.aspx?v=2&where1=’ + AddLine1 + ‘,’ + AddCity +  ‘,’ + AddState + ‘,’ + AccountZip ;
if (MapURL != null)
{
crmForm.all.IFRAME_map.src = MapURL;
}
}
else
{
// alert(‘no address’);
}
}

3) Customize the form and do the following:
a) Add the BingMap web resource to the form library
b) Add the bingmap function web resource to the form event handler

BingMapImage
4) Publish the form.

In this screenshot I have made a custom “Land” entity and integrated BingMaps.
LandMap
Following these easy steps will allow BingMaps to work in your Microsoft Dynamics CRM 2011 environments.

Posted in JavaScript, Microsoft Dynamics CRM 2011 | Tagged: , , , , , , , , , | Leave a Comment »