Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

CRM 2011 C# - Clone activity

$
0
0

I’ve found a lot on this but I can’t get it to work L

The simplest way seems to just get the entity and replace the ID with a new one, but the new ID doesn’t replace the old? 

This is based on this post: http://www.tribridge.com/Blog/crm/default/2011-07-28/Cloning-a-Record-in-Dynamics-CRM-2011.aspx
I've tried this (http://msdn.microsoft.com/en-us/library/gg678489.aspx) also but I'm getting reference issues with Microsoft.Xrm.Client, and I have referenced correctly...

Any ideas?

Entity _entity = new Entity(entityName);
                _entity = service.Retrieve(_entity.LogicalName, entityID, new ColumnSet(true));

                Entity clone = new Entity(entityName);

                clone = _entity;

                clone.Attributes.Remove("statuscode");
                clone.Attributes.Remove("statecode");
                clone.Attributes.Remove("activityid");
                clone.Id = Guid.Empty;

                clone.Id = Guid.NewGuid();

                if(clone.Id == _entity.Id)
                {
                    throw new Exception("THE SAME ID");
                }

                service.Create(clone);


Viewing all articles
Browse latest Browse all 8223

Trending Articles