Hi
I am creating a clone of record on it's create. Plugin is registered on post-create of the record.
QueryExpression qe = new QueryExpression("contact")
{
ColumnSet = new ColumnSet("firstname", "lastname")
};
EntityCollection entityCollection = _organizationService.RetrieveMultiple(qe);
foreach (Entity entity in entityCollection.Entities)
{
if (!entity.Attributes.Contains("firstname"))
{
entity.Attributes.Add("firstname", "");
}
entity["firstname"] = (entity.GetAttributeValue<string>("firstname") ?? "") + "(Copy)";
_organizationService.Create(entity);
}
If I do not Entity.Id = Guid newGuid() for the clone record, it gives me "Cannot insert duplicate key"
If I add Entity.Id = Guid newGuid(), it gives me "Entity Id must be the same as the value set in the property bag.
Can you help please?
Thanks
Arj
*This post is locked for comments