Thursday, 19 May 2011

Simple Google Maps in MS Dynamics CRM 4.0

Lately I've been looking at adding google maps to our MS Dynamics CRM 4.0 install. While there are plenty of guides to adding it yourself, most seem overly complex for the task required or need a lot of editing to be functional. Here's a quick, general-use case for adding embedded google maps to CRM 4 entities.

A few notes:
  • All hard-coded variables should work on these entities: Account, Contact, Business unit, and Competitor. For custom entities, you'll need to change the variables.
  • This assumes you're putting the map in an iframe on it's own tab. You'll need to know the names of both.
  • It performs no input validation or removal of illegal characters. Malformed addresses might display incorrectly as a result.

This code should go in the onload form of the entity:

//// Simple Embedded Google Maps in an iframe ////

var maptab = crmForm.all.tab2Tab; // your map tab here
var mapiframe = document.all.IFRAME_map; //your iframe name here

// Load map when the map tab is clicked
maptab.onclick = function() {

//// Loads map into iframe when called //
DrawMap = function() {
    if (crmForm.FormType == 1)
    { mapiframe.src = "about:blank"; }
        // Build the address for google maps 
        var mapUrl = "";
        if (crmForm.all.address1_line1.DataValue != null) 
            { mapUrl = mapUrl + crmForm.all.address1_line1.DataValue + "+"; }
        if (crmForm.all.address1_line2.DataValue != null) 
            { mapUrl = mapUrl + crmForm.all.address1_line2.DataValue + "+"; }
        if (crmForm.all.address1_line3.DataValue != null) 
            { mapUrl = mapUrl + crmForm.all.address1_line3.DataValue + "+"; }
        if (crmForm.all.address1_city.DataValue != null) 
            { mapUrl = mapUrl + crmForm.all.address1_city.DataValue + "+"; }
        if (crmForm.all.address1_stateorprovince.DataValue != null) 
            { mapUrl = mapUrl + crmForm.all.address1_stateorprovince.DataValue + "+"; }
        if (crmForm.all.address1_country.DataValue != null) 
            { mapUrl = mapUrl + crmForm.all.address1_country.DataValue; }
        //Check if there's no address information
        if ( mapUrl == "" )
            mapiframe.src = about:blank;
        else {
            mapUrl = "" + mapUrl + "&output=embed&t=m";
            mapiframe.src = mapUrl;

What this does:
  • Waits for the map tab to be clicked and then calls the DrawMap function (this saves time loading the form)
  • Checks to see if the entity is being created, in which case it will blank out the map.
  • Loads any address values that contain data into mapUrl value
  • Checks that the address actually contains data, and if so:
  • Loads that url into the iframe.
At the end of it, you have something that looks like this:

My example here is slightly different - if selected, the radio buttons above will re-load with directions from our office.

It's surprising just how much you can do by passing parameters in the google maps URL. This example defaults to 'embedded' viewing with output=embed and t=m, but you can use it for quite a few other things like getting directions using saddr and daddr, pull up streetview with cbp=, and a whole range of other things. Mapki seems to have a pretty good list of the known parameters here.

You can quickly and easily integrate google maps with CRM 4, and it makes a lot of tasks incredibly easy. With only a little more work, you could have it throwing up a list of directions from any arbitrary point to any address in your system.


  1. CRM are the best software that any company could rely on to maintain their relationship with their customers. Apart from other CRM in the market Salesforce offers a great interface to take care of these activities. They also offer in house interaction facility. Thanks to salesforce.

    Salesforce developer training in chennai
    Salesforce administrator training in chennai


    1. - Tộc trưởng, số người trong viễn cổ hổ tộc vô cùng nhiều, chúng ta làm sao để cứu người?

      Nhạc Hạo tiến tới hỏi Nhạc Thành.

      - Chuyện cứu người mọi người không cần phải lo lắng, ở trong Viễn Cổ Hổ Tộc, chỉ cần gặp người của bọn họ là giết không tha.

      Nhạc Thành bình tĩnh trả lời.

      - Vậy còn nhữndongtam
      mu private
      tim phong tro
      nhac san cuc manh
      tổng đài tư vấn luật
      văn phòng luật
      tổng đài tư vấn pháp luật
      thành lập công ty
      chém gió
      trung tâm ngoại ngữg phụ nữ trẻ em thì sao?

      Nhạc Hạo cất tiếng hỏi Nhạc Thành.

      Sắc mặt của Nhạc Thành biến hóa, hắn suy nghĩ một lúc rồi nói:

      - Nếu Hắc Ám Thần Điện cùng Tam Đại Thú Tộc tới Nhạc gia thì sẽ tha cho phụ nữ và trẻ em của Nhạc gia hay sao, chỉ cần là người của Viễn Cổ Hổ Tộc thì giết không ta, tuy nhiên chúng ta bỏ qua người bình thường cũng là việc nên làm, còn người tu luyện thì một người cũng không bỏ

  2. There are lots of information about latest technology, like Hadoop cluster is a special type of computational cluster designed specifically for storing and analyzing huge amounts of unstructured data in a distributed computing environment. This information seems to be more unique and interesting. Thanks for sharing.
    Hadoop Training Chennai | Best Hadoop Training in Chennai | Big Data Training

  3. Welcome to Wiztech Automation - Embedded System Training in Chennai. We have knowledgeable Team for Embedded Courses handling and we also are after Job Placements offer provide once your Successful Completion of Course. We are Providing on Microcontrollers such as 8051, PIC, AVR, ARM7, ARM9, ARM11 and RTOS. Free Accommodation, Individual Focus, Best Lab facilities, 100% Practical Training and Job opportunities.

    Embedded System Training in chennai
    Embedded System Training Institute in chennai
    Embedded Training in chennai
    Embedded Course in chennai
    Best Embedded System Training in chennai
    Best Embedded System Training Institute in chennai
    Best Embedded System Training Institutes in chennai
    Embedded Training Institute in chennai
    Embedded System Course in chennai
    Best Embedded System Training in chennai

  4. Cloud servers are the best in safe guarding one's information thorugh online. Without this dedicated methodology many companies would have not existed at all. The same though has been furnished above. Thanks for sharing this worth while content in here. Keep writing article like this.

    Salesforce Training in Chennai | Salesforce training | Salesforce admin training in chennai

  5. Best SQL Query Tuning Training Center In Chennai This information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic..

  6. Great blog..You have clearly explained about the concept..Step by step explanation is too good to understand..Its very useful for me to understand..Keep on sharing..
    Hadoop training in chennai

  7. Thanks for sharing informative article on java application development. Your post helped to understand the career in Java. JAVA Training in Chennai

  8. Thanks for sharing this informative content which provided me the required information about the latest technology.
    Salesforce training in Chennai | Salesforce CRM training in Chennai

  9. In coming years, cloud computing is going to rule the world. The cloud based CRM tool provider like Salesforce have massive demand in the market. Thus talking salesforce training in Chennai from reputed Salesforce training institutes in Chennai will ensure bright career prospects for aspiring professionals.

  10. Every business requirement is different so before selecting the CRM software organization should keep in mind the various factors. CRM Philippines

  11. Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. crmcare

  12. Many thanks for creating the effort to talk about this, I feel strongly about this and love learning a great deal more on this subject. If feasible, as you gain knowledge, would you mind updating your website with a great deal more information? It’s extremely beneficial for me. crm software hong kong, malaysia, singapore

  13. I’d love to be a part of group where I can get advice from other experienced people that share the same interest. If you have any recommendations, please let me know. Thank you.
    fire and safety course in chennai

  14. Emotion Spitfire SOT inflatable kayak is stable and tracks well in moderate water conditions.

    1 person recreational sit on top kayak