Dynamics 365 with Google Maps for Address Lookup

Post Date: June 7, 2017

Microsoft Dynamics Consultant

[vc_row][vc_column][cq_vc_zoomimage displaystyle=”magnify” magnifyimage=”6845″ bordercolor=”#ffffff” glassx=”50″ glassy=”110″][vc_separator][vc_empty_space height=”50px”][vc_wp_text title=”Summary”]One of the most common requirements requested by Clients is the address lookup functionality. OTB (Out-the-box) Microsoft Dynamics doesn’t have any address lookup capabilities. There is some integration with Microsoft Bing, but this feature only displays a map and does not resolve to an actual address.

In this post, I’m going to demonstrate how easy it is to use Google Maps and Dynamics CRM to provide address Lookup functionality.

[/vc_wp_text][/vc_column][/vc_row][vc_column][/vc_column][vc_row][vc_column][vc_wp_text]Just before I begin I want to point out that Google manages interaction with their services through licences. As of June 2017, you can carry out 1000 postcode searches without the need to purchase a licence on the free subscription, your use case may differ if you intend to use this differently. My advice is; read through the documentation here: https://developers.google.com/maps/pricing-and-plans/ then select the license based on your use case, if you want to implement the Google address lookup feature into a production environment.[/vc_wp_text][vc_empty_space][vc_wp_text title=”What are we going to accomplish?”][/vc_wp_text][vc_wp_text][/vc_wp_text][vc_wp_text title=”How it works”]

  • You enter a postcode in the CRM Text Field.
  • A function called GetPostCodeValue() is triggered. This function extracts the postcode that you entered in CRM.
  • Google Maps is then queried with the postcode extracted using Google Maps API.
  • The address returned, is then automatically populated in Dynamics CRM.

[/vc_wp_text][/vc_column][/vc_row][vc_row][vc_column][vc_wp_text title=”Source Code”]We’re going to be using JavaScript to query the Google Maps API. Here is the code that takes the postcode details, sends it to Google Maps and returns the address, automatically populating the Dynamics 365 fields:[/vc_wp_text][vc_wp_text]


[/vc_wp_text][vc_wp_text]Note: I have commented out city2 & city3 because it’s not needed for what I’m trying to do. If you need to customise what is returned, your first starting point should be: https://maps.googleapis.com/maps/api/geocode/json?address=W1A%201AA[/vc_wp_text][/vc_column][/vc_row][vc_row][vc_column][vc_wp_text title=”Technical Points”]

  • Requires JQuery, so make sure to include this with your solution.
  • The data returned (address) is an object. You can query the object further to fine tune your results:


[/vc_wp_text][/vc_column][/vc_row][vc_row][vc_column][vc_wp_text title=”I just want the solution”]If you just want to install the solution file without writing the code to test this out for yourself; you can download the solution file here:  Google Maps Dynamics 365 Solution (304 downloads)

Once downloaded, import the solution into your test organisation and publish. You will have to add the two libraries: GMPostCodeLookup.jsJqueryMin.js. into the Contact form.

Once you’ve done that be sure to hook up the OnChange event to the postcode field:

[/vc_wp_text][/vc_column][/vc_row][vc_row][vc_column][vc_wp_text title=”Final Words”]

  • The same code can be used for any entity; this includes the Account entity or a custom entity.
  • Make sure to check the license type that you need with Google.


There are 7 Comments

  1. Posted by Joseph Reply


    how would you do this for Composite fields ??

    not really sure how to get this to work.

    thank you,

    • Posted by Syed Hussain Reply

      This will still work for composite fields. It shouldn’t make a difference.

  2. Posted by naresh Reply

    Will it directly navigates into our google maps when we click on on the location. I tried in mobile app it was not navigating to the google map.

    • Posted by Syed Hussain Reply

      This doesn’t navigate to Google Maps. I might add this item in when I have time.

  3. Posted by Adam Posegate Reply

    Do you have plans to update this for the v9 web api code changes related to Xrm.Page.GetAttribute?


    thanks for the help
    but how can i make a link to the bing maps instead og google maps ?

  5. Posted by Roman Reply

    I added the managed solution. I don’t believe this is working anymore. Line 17 of javascript code is getting this message “Unable to get property ‘geometry’ of undefined or null reference”.

Leave a Reply to Lucasfusty

Click here to cancel reply.