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.