Here's another in a series of Microsoft Dynamics CRM customization walkthroughs.

CRM Customization: How to copy an entire address

Copying an address from an account record in Dynamics CRM can be a little bit tricky. If you click in the address box itself, then highlighting the address opens the address editor and de-selects the address text:

Microsoft CRM 2015 address

However, with a little quick web development, we can add a web resource to a make it much easier to copy the address. First, create a web resource called AddressCopyButton.html and upload it as a new web resource. The web resource should have the following code:


<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
body, html {
margin:0px;
padding:0px;
height:100%;
width:100%;
}
input[type="button"] {
width:100%;
height:100%;
}
</style>
</head>
<body>
<script>
function OpenCopyAddressDialog() {
var fieldAddress = parent.Xrm.Page.getAttribute('address1_composite');
//check if field1 is on form
if (fieldAddress === null || fieldAddress === 'undefined') {
alert('address1_composite' + ' is missing from form!')
return;
}
//get values
fieldAddressValue = fieldAddress.getValue().replace(/(?:\r\n|\r|\n)/g, '<br />');
parent.$('#CopyAddressDiv').html(fieldAddressValue);
parent.$('#CopyAddressDiv').dialog('open');
return false;
};
parent.$(function () {
// append the jQuery dialog cascading stylesheet to the main form so that the dialog will look ok
parent.$('head').append("<link rel='stylesheet' href='//code.jquery.com/ui/1.8.21/themes/smoothness/jquery-ui.css'>");
parent.$('head').append('<style type="text/css">.CopyAddress .ui-dialog-titlebar { margin-top:0px; margin-bottom:0px; }<style>');
// add the div to the page
parent.$('body').append("<div id='CopyAddressDiv' title='Copy The Address' style='background-color:#eee; text-align:center;'></div>");
parent.$('#CopyAddressDiv').dialog({
title: "Copy Address From Here",
height: 200,
width: 350,
autoOpen: false,
dialogClass: 'CopyAddress'
});
});
</script>
<input type="button" value="Copy Address" onclick="OpenCopyAddressDialog();" />
</body>
</html>


Then, edit your form and insert a web resource below your address block with the source set to the web resource you just uploaded.

This makes use of jQuery and jQuery UI already built into Dynamics CRM 2015 (you can add the necessary references for previous versions of CRM) to show a simple dialog to make it easy to copy the address. For more CRM customization examples, click here.

microsoft dynamics CRM customization 2015 screenshot copy address

InterDyn Artis is the Carolinas leading provider of CRM and ERP solutions. Our team of experts provide implementation and consulting services to businesses throughout the Carolinas. If you have a CRM customization request, you may contact us at (704) 846-6750 or by sending our team an email at info@interdynartis.com.

Microsoft Dynamics CRM Customization: Copy Address Dialog is a post from: CRM Software Blog

The post Microsoft Dynamics CRM Customization: Copy Address Dialog appeared first on CRM Software Blog.