locked
Inside CRM How to Use Bing Map Service (form onload) using javascript RRS feed

  • Question

  • Hello CRM Experts

    I want to use Bing Map CRM inside CRM form I used to call the Service 

    on CRM form I got "Microsoft" is Undefined error. Please suggest how can I do that ..  My code is like this




    var where;


    function PopulateGeocodes() {
        debugger;
        var type = Xrm.Page.ui.getFormType();
        crmStreet = Xrm.Page.data.entity.attributes.get("address1_line1").getValue();
        crmLatitude = Xrm.Page.data.entity.attributes.get("techno_latitude").getValue();
        crmLongitude = Xrm.Page.data.entity.attributes.get("techno_longitude").getValue();
        crmCity = Xrm.Page.data.entity.attributes.get("address1_city").getValue();
        crmState = Xrm.Page.data.entity.attributes.get("address1_stateorprovince").getValue();
        crmZip =Xrm.Page.data.entity.attributes.get("address1_postalcode").getValue();
        crmCountry = Xrm.Page.data.entity.attributes.get("address1_country").getValue();

        // check for form create or update 
        if (type != 1) {

            if (crmLatitude != null && crmLongitude != null) {
                where = crmStreet + ", " + crmCity + ", " + crmState + " " + crmZip;
                LoadSearchModule();
            }
            else {
                return;
            }
        }


    }



    function getMap() {
        map = new Microsoft.Maps.Map({ credentials: 'Aqg2XmIT10BlfDpHXvTkVTJGFGPBG8sH7CnP5aPukNRJv8Uaexv1XzB7c1Wo8qX-' });
    }
    function createSearchManager() {
        map.addComponent('searchManager', new Microsoft.Maps.Search.SearchManager(map));
        searchManager = map.getComponent('searchManager');
    }
    function LoadSearchModule() {
        Microsoft.Maps.loadModule('Microsoft.Maps.Search', { callback: geocodeRequest })
    }
    function geocodeRequest() {
        createSearchManager();
       // var where = 'Denver, CO';
        var userData = { name: 'Maps Test User', id: 'XYZ' };
        var request =
        {
            where: where,
            count: 5,
            bounds: map.getBounds(),
            callback: onGeocodeSuccess,
            errorCallback: onGeocodeFailed,
            userData: userData
        };
        searchManager.geocode(request);
    }
    function onGeocodeSuccess(result, userData) {

        if (result) {
            map.entities.clear();
            var topResult = result.results && result.results[0];
            if (topResult) {
                var pushpin = new Microsoft.Maps.Pushpin(topResult.location, null);
                map.setView({ center: topResult.location, zoom: 10 });
                map.entities.push(pushpin);
                Xrm.Page.data.entity.attributes.get("techno_latitude").setSubmitMode("always");
                Xrm.Page.data.entity.attributes.get("techno_longitude").setSubmitMode("always");
                Xrm.Page.getAttribute("techno_latitude").setValue(topResult.location.latitude);
                Xrm.Page.getAttribute("techno_longitude").setValue(topResult.location.longitude);
                
            }
        }
    }

    I am calling one function on form onload event but I got error please suggest how to do that.



    • Edited by 2014crm Thursday, August 22, 2013 3:04 PM
    Thursday, August 22, 2013 2:55 PM

All replies

  • Just out of curiosity, what entity are you trying to get this to work for?
    Friday, August 23, 2013 7:23 AM
  • Hi thanks for reply.

    For Account Entity.  can u suggest any thing for this..

    Thanks

    murali 

    Friday, August 23, 2013 10:03 AM
  • Next question is, which Rollup are you using? The new process forms include a Bing map for the account form by default.
    • Proposed as answer by Roshan Mehta Friday, August 23, 2013 10:39 AM
    Friday, August 23, 2013 10:39 AM
  • Hi I am using CRM Rollup11 

    Monday, August 26, 2013 1:47 PM