GeoCode Plugin using Google Maps or BING Maps


In my previous post, I talked about building a Custom Workflow Activity that works for CRM 2011 Online and CRM 2011 On-Premise. Now decided to build a geocoding plugin which will do the same, except it is like Turbo the snail. Designed it in such a way, you can make this to work for any Entity, OOB or Custom and for any number. Any secrets, naaaahhhhh. Just plain old CRM. That’s what I like about CRM. It is LEGO blocks. No end to creativity. Created a config entity to hold all config data, be it Google Maps or Bing Maps. Ok, enough of the blah, blah, blah. Just get to the meat will ya. I felt there might be a need to goecoding to be synchronous, rather than a workflow. Well with 2013, that will change with Realtime Workflows.


In this post I will deal with deploying, customizing and seeing the results of the plugin executing. Will post the source code online at Codeplex( when I make myself a bit free. Will provide a managed solution with just the plugin and config entity.

Step 1: Import Maps Solution.

Once you import the solution, you should see a new Group on sitemap under settings called E31 Maps. This will give you access to Geocode Config entity.

Step 2: Geocode Config Entity entries

In this step, I’m assuming you are adding a record to geocode an address in Account entity.

Entity Name = account(this is the logical name, not schema name of the entity).

Keeping with the above guideline, please fill in the names of the fields that are the key players in the geocoding process.


  • Entity Name
  • Bing Maps Key ( can be empty when using google maps url)
  • Bing Maps Url, or Google Maps Url
  • Street Field(name of the field in contact entity which hold the Street Address value)
  • City Field (name of the field in contact entity which hold the City value )
  • State Field (name of the field in contact entity that holds the State or Province value)
  • Postal Code Field (name of the field in the contact entity that holds ZIP code value)
  • Country Field


  • Latitude Field (name of the field that will hold geocoded Latitude value in contact entity)
  • Longitude Field (name of the field that will hold the geocoded Longitude value in contact entity).

Example of screenshot for Account entity:


Geocode Config record values for geocoding Account entity using BING Maps

Step 3a: Plugin Registration – New Step for CREATE

Once the Plugin is registered as part of the installation of the managed solution, fire up the Plugin registration tool supplied with 2011 SDK. Create a new STEP for this assembly as shown below.


STEP Configuration settings for Account CREATE Message

Step 3b: Plugin Registration – New Step for UPDATE

Want to finish the configuration for the UPDATE message so that you can go ahead and fire up the plugins by creating accounts or updating accounts.

  1. Create a new STEP for the assembly for the UPDATE message,
  2. In the Step Configuration section, please select the Filtering attributes to be Input attributes as mentioned in the previous section. The 5 attributes are a) Street, b) City, c) State, d) Zip and e) Country.
  3. Fill in other parts of the Step configuration screen as shown below.


    STEP Configuration settings for Account UPDATE Message

  4. Create a PreImage for the UPDATE message step. It is important that I know the records previous address information before the change occurred. Set up the PreImage for these 5 fields. Mainly the ones that you need to compare with the changed values. These fields are picked from the entity for which you registered UPDATE step for. In our case we are dealing with Account. Select these 5 fields only for the PreImage address1_city, address1_country, address1_stateorprovince, address1_line1, address1_postalcode

    PreImage Setting for Account UPDATE step.

    There you go. You are done. Way the geocoding works is pretty simple. For a Create message, no need for any explanation. I pass in values that are available to the BING Maps geocode api. Bing maps returns a result and result quality(next release). For the Update operation, it is little bit tricky. CRM will send only the fields that changes to the event. In the case for fields that have not changed I get the value from PreImage. then I do the usual processing in passing all values that are parts of the address to the geocode API. Viola. I tested with CRM Online and works. Now you need to tell me if there are other features that must be added to this and if it is performing well.

NOTE: It is up to you as a developer to register the appropriate STEPS for the respective Geocode API, if it is BING or GOOGLE. This article is primarily is focused on BING Maps API. I’m working on a release of the plugin that uses Google Maps API. Both plugins will make use of Geocode Config entity to decide where the address fields are in the entity record in question.

As always comments are welcome. enjoy!

Download Solution :



GeoCode Workflow Activity for Dynamics CRM 2011


Finally, I got to complete two new custom workflow activities to GeoCode any CRM entity(OOB or Custom) using BING Maps or Google Maps. I started to look into Nokia Maps and kind of got lost in their HERE site. So lets dive into the details. This is the start of my passion for creating solutions that using mapping to present information to users. This passion started when working at Primedia ( My first exposure to Google Maps. Taking this to the next level by creating solutions that can be used within Dynamics CRM 2011, the ultimate extensible CRM platform.

This post will focus on a CRM power user creating a workflow incorporating these workflow activities. Don’t want to do injustice to the technology that went behind the workflow activities, which is REST service from map providers. Will discuss this aspect in more details in another post. Built this solution using a) Developers toolkit (SDK 5.0.13), Visual Studio 2012, and REST services provided BING Maps and Google Maps. Check Resources section at the bottom the blog, where I provide the links. Additionally, if you download the source from CodePlex, the workflow Activities themselves have the article and links in them.

NOTE: I’ve tested the workflow activities on an on-prem deployment only. Will test crm online and post any updates soon.

Update for CRM Online: Oct. 9th, 2013

I’ve tested the Google Maps custom workflow for CRM Online and workflows is working like a charm. When you register from source code, make sure to select Isolation Model = Sandbox. I’ve removed other errors about Partial Trust issues. Going to provide two solutions, one for Google Maps and one for BING Maps. Check CodePlex for individual solutions.

BING Maps Geocode Activity:

Using BING Maps REST Services Location API some more help from articles published on the MSDN sites, created this workflow activity. In order to get this going, follow instructions to obtain BING Maps Key from Account Center. We will walk through an example of Geocoding an account entity.

  1. Obtain BING Maps key from Bing Maps Account center. Create a new App to Specify the site as http://localhost .

    1. BingMapsKey

  2. Create a workflows that can run as an “On-Demand Process”. You can definitely make this process to run when a) Record is created and b) Record is updated and track the Address1, Address 2. You can Geocode more than one Address, by using the activity in multiple steps.
    2. Activities
  3. Set the Properties that are the input for the Bing Maps activity. a) Bing Maps Key b) Street c) City d) State e) Zip f) Country (ISO Code) . In this I did not spend too much effort in figuring out what makes good address, such as we need at least a ZIP to GeoCode. I will leave this as an exercise you can customize for your needs.
    3. BingMapsProperties
  4. GeoCode activity provides 3 output params a)Lat b) Long and c) GeoCodeResult. One more upgrade that I can do is to provide the quality of the result as an output params that can incorporated into the workflow.
    4. BingMapsOutput_LatLong
  5. Output param GeoCodeResult provided two pieces of info, a)BING Maps Geocode URL and b) first 1750 chars of the XML returned by executing the URL. Little bit about the URL. I use an Unstructured URL, which allows each part of the address to used based on what values are available as part of input params. You can take this URL and navigate in IE, since the output type that I ended up using is XML and view results. Helps with debugging results.
    5. BingMapsOutput_Result
  6. In the example solution provided on CodePlex, you take outputs Lat and Long and update the Account entity and output params Result is used to create a Note.

Next posts will delve into the details of what is happening within the activity when you Geocode an address. Additionally will be updating the CodePlex project with Geocode plugins for Account, Contact and Site. Well if you figure out for one, rest is the same. Will take baby steps. Want to build a SilverLight app that use make use of Bing Maps SilverLight control, make use of SQL 2008 Spatial querying.

Please provide any and all feedback to incorporate into these map utilities. Thanks for your time.

– P


  1. BING Maps account Center:
  2. BING Maps REST API :
  3. Unstructured URL: Get the latitude and longitude coordinates based on a set of address values for any country:
  4. CodePlex – Maps for CRM 2011 :