Google Maps For Ms CRM Forms


Recently , we have a requirement from client , to show the address on google maps. To achieve this requirement, By default we are going with Bing Maps. But if you goes with Bing Maps, It will asks the AcessKey (Not for trail instances). We have to buy the access key from MS. So client doesn’t approve this method. Alternately we are achieving the requirement thorough google maps via adding new WebResource as HTMl Page on a form.

Default On loading the form, It will shows the Hyderabad as base address with latitude and longitudes (17.384509, 78.486156).


Add  new section and place anywhere within your Account Form. Am  placing the new Section below the Address Composite Field and labeled the Section as “googlemaps”.


Place the cursor on the new section and click on insert – select new web-resource


Add the new web resource with type Html as follows



Paste the following html code inside that Text Editor- Source

//Google Maps Code- with default Hyderabad location// //if u want to change then, change the latitude and Longitudes.


 function Map() {
 var map_canvas = document.getElementById('map_canvas');
 var map_options = {center: new google.maps.LatLng(17.384509,78.486156),zoom: 16,mapTypeId: google.maps.MapTypeId.ROADMAP}
 var map = new google.maps.Map(map_canvas, map_options)
 var geocoder = new google.maps.Geocoder();
 var address ='address1_composite').getValue();
 geocoder.geocode( { 'address': address}, function(results, status) {
 if (status == google.maps.GeocoderStatus.OK) 
 var marker = new google.maps.Marker({map: map, position: results[0].geometry.location});
 else {
 //alert("Geocode was not successful for the following reason: " + status);
 google.maps.event.addDomListener(window, 'load', Map);

</body> </html>
While uploading the code , word press doesn’t allowing some  lines of code at script and div. Please Go through Image.

After Pasting the code, click on Add Option 




Click on Save And Publish.6

Creating a new account record. , it will shows the Default Hyderabad location.Screenshot (328)

If we have data on the address composite field then Refresh the form and  it will shows the output as follows.



Crming- Enjoy 🙂



Clone A Record

Clone A Case Record :

Cloning is one of the methods which can reduce the time spent on data entry, particularly if the same case record data being entered is similar.

Cloning or Record Copying allows you to create a duplicate record with the same values as the parent record with just one click.

Solution as follows:

Ribbon Button will be visible on the  case form, Once Record is Saved , then Button will be visibled. If he click on the Button open a dialog, with message “Do You want to clone a a case Record” If he click Ok , It will Cloning the record.

flow – Button – click- Js pass Id to – Action InputParameter- Plugin Trigger – Create Case record.

Ribbon workbench Button as follows :-


Add the Button Command As Follows :-

Action – web resource and Function Name -“CallAction


Display Rule As Follows : Form StateRule


Js Code For Ribbon WorkBench Action :-

 function CallAction() {
 var formtype = Xrm.Page.ui.getFormType();
 Xrm.Utility.confirmDialog("Do You want copy the case Record?", 
 function () {
  var recordId ="{", "").replace("}", "");
 // action schemaname "new_a" and passing record id to the action parameter(first and second are parametrs) and 
 //under function BuildActionRequestXml seee the two parameters am using only one parameter and passing id to the parameter
 InvokeAction("new_CloneaCaseGuid", recordId);
 function () {});
function InvokeAction(actionName,recordId) {
 var xmlHTTPRequest = new XMLHttpRequest();
 var results = true;"POST", Xrm.Page.context.getClientUrl() + "/XRMServices/2011/Organization.svc/web", false);
 xmlHTTPRequest.setRequestHeader("Accept", "application/xml, text/xml");
 xmlHTTPRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
 xmlHTTPRequest.setRequestHeader("SOAPAction", "");

 xmlHTTPRequest.onreadystatechange = function () {
 if (this.readyState == 4) {
 if (this.status == 200) {
 //if required write code here.
 else {
 results = false;

function BuildActionRequestXml(actionName,recordId) {
 var requestXml = "<s:Envelope xmlns:s=''>" +
 "<s:Body>" +
 "<Execute xmlns='' xmlns:i=''>" +
 "<request xmlns:a=''>" +
 "<a:Parameters xmlns:b=''>" +
 "<a:KeyValuePairOfstringanyType>" +
 "<b:key>Guid</b:key>" +
 "<b:value i:type='c:string' xmlns:c=''>" + recordId + "</b:value>" +
 "</a:KeyValuePairOfstringanyType>" +
 //"<a:KeyValuePairOfstringanyType>" +
 //"<b:key>second</b:key>" +
 //"<b:value i:type=\"c:string\" xmlns:c=\"\">" + + "</b:value>" +
 //"</a:KeyValuePairOfstringanyType>" +
 "</a:Parameters>" +
 "<a:RequestId i:nil='true' />" +
 "<a:RequestName>" + actionName + "</a:RequestName>" +
 "</request>" +
 "</Execute>" +
 "</s:Body>" +
 return requestXml;


Next Global Action Create Input Parameter as Guid with Type String :

Screenshot (116).png

Through Javascript , Button Onclick, we are passing the case record Id to the this InputParameter Guid. Once Action Called Then Plugin will Trigger to create the Case Record .

Plugin Step As Follows : Message Name = Action Name “new_CloneaCaseGuid14.JPG

Plugin Code To create the copy case Record as Follows:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Crm.Sdk.Messages;

namespace Clone_a_Record
 public class Class1 : IPlugin
 public void Execute(IServiceProvider serviceProvider)
 IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
 ITracingService tracing = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
 IOrganizationServiceFactory servicefactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
 IOrganizationService service = servicefactory.CreateOrganizationService(context.UserId);
 if(context.InputParameters.Contains("Guid") && context.InputParameters["Guid"] is string)
 Guid CaseID = new Guid(context.InputParameters["Guid"].ToString());
 Entity cases = service.Retrieve("incident", CaseID, new ColumnSet(true));

 //Initialises new record from an existing record
 InitializeFromRequest copyCases = new InitializeFromRequest();
 copyCases.TargetEntityName = "incident";
 copyCases.EntityMoniker = cases.ToEntityReference();
 copyCases.TargetFieldType = TargetFieldType.All;
 InitializeFromResponse response = (InitializeFromResponse)service.Execute(copyCases);
 Entity newCase =(Entity) response.Results["Entity"];



It Will doesn’t clones the child Records.

That’s It It will Clones the Record;

Enjoy 🙂