web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :

Duplicate Record

migsbeja Profile Picture migsbeja 655

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)
{
	try
	{
		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.


Filed under: C#, Dynamics CRM, Javascript

This was originally posted here.

Comments

*This post is locked for comments