Monday, November 04, 2013

Microsoft CRM 2013 - Integration with BingMaps: difference between OnPremise and Online instances

Difference I faced today is following – OnPremise instance has Bing Map api key field in System Settings but Online doesn’t.

In case you build solutions that uses BingMapKey in other way then OOB BingMap control and make solution works the same way both OnPremise and Online you can manually update this field through code:
QueryExpression query = new QueryExpression("organization")
    ColumnSet = new ColumnSet(false)

Entity organization = service.RetrieveMultiple(query).Entities.FirstOrDefault();
organization["bingmapsapikey"] = "Your Bing Maps API Key";

In case you want to use your key somewhere in .Net code (plugins, custom workflow activities, external applications) you can use following code to get value of this key:

string bingmapkey = null;

QueryExpression organizationQuery = new QueryExpression("organization")
    ColumnSet = new ColumnSet("bingmapsapikey")

Entity organization = service.RetrieveMultiple(organizationQuery).Entities.FirstOrDefault();

if (organization != null && organization.Contains("bingmapsapikey"))
    bingmapkey = organization.GetAttributeValue<string>("bingmapsapikey");

//Usage of bingmap api key