Duplicate Record

Have you ever had a client that needed a functionality like this and the Dynamics CRM still doesn’t do it?

You can accomplish this with a simple code that you can put in a button in the ribbon.

You can accomplish this with a ASP.NET (if you are On-premise) page or a HTML web resource (Online). For this example I’m using the ASP.NET.

protected void Page_Load(object sender, EventArgs e)
		CopyEntity copy = new CopyEntity();
		string newEntityID = copy.CopyEntity(base.Request.QueryString["Id"].ToString(), base.Request.QueryString["user"].ToString());
		string str = ConfigurationManager.AppSettings["Server"].ToString() + @"/" + base.Request.QueryString["org"].ToString() + "/main.aspx?etc=" + ConfigurationManager.AppSettings["EntityType"].ToString() + "&id=%7b" + newEntityID + "%7d&newWindow=true&pagetype=entityrecord";
		base.Response.Write("window.location.replace('" + str + "')");
	catch (Exception ex)
		throw new Exception(ex.Message);

When you do copy.CopyEntity, you have a class that you implement the logic to copy the record (query the selected record to get the data of the fields and create a new one) that is selected in the Homepagegrid or Form.

You can have this in a button, that invokes a Javascript that will call this page for example.

function callCopyEntity() {
	var userid = Xrm.Page.context.getUserId();
	var guid = Xrm.Page.data.entity.getId();
	var url = "connection";
	var address = url + guid + '&user=' + userid;
	window.open(address, 'DuplicateEntity', 'menubar=no,resizable=yes,toolbar=yes,location=yes');

This is an easy implementation that will allow the user to copy the records easily, which would have to create manually, having to change only the information that finds necessary.

Hope this helps.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s