Hello All,
I want to delete duplicate contact records on the basis of duplicate "Email" addresses from 2011 dynamics CRM version. Could anyone please suggest me here.
Thanks,
*This post is locked for comments
Hello All,
I want to delete duplicate contact records on the basis of duplicate "Email" addresses from 2011 dynamics CRM version. Could anyone please suggest me here.
Thanks,
*This post is locked for comments
Hi Tin,
if you solved the problem thanks to an answer, please mark it as verified to encourage the community to provide more and more a better support. Thank you. Francesco
If you found the answer helpful, please mark as Verified
Join my network on LinkedIn Follow me on Twitter
Thank You & Best Regards
Francesco Picchi
Microsoft Dynamics CRM Consultant, Bologna+Milano, ITALY
Independent Contractor
Hi Tin ,
there is the duplication detect tool of CRM, but is a one-o-one job.
I think you need a batch job.
I wrote it down for you.
public static void DeleteDuplicatedContacts(IOrganizationService svc) { List<string> emailaddresslist = new List<string>(); QueryExpression query = new QueryExpression("contact"); query.ColumnSet = new ColumnSet("emailaddress1"); query.Criteria.AddCondition("emailaddress1", ConditionOperator.NotNull); query.Orders.Add(new OrderExpression("emailaddress1", OrderType.Ascending)); List<Entity> entitylist = svc.RetrieveMultiple(query).Entities.ToList(); foreach (Entity entity in entitylist) { string emailaddress = entity.GetAttributeValue<string>("emailaddress1"); if (!emailaddresslist.Contains(emailaddress)) emailaddresslist.Add(emailaddress); else svc.Delete(entity.LogicalName, entity.Id); } }
Please let me know if you solve.
If you found the answer helpful, please mark as Verified
Join my network on LinkedIn Follow me on Twitter
Thank You & Best Regards
Francesco Picchi
Microsoft Dynamics CRM Consultant, Bologna+Milano, ITALY
Independent Contractor
Thanks Francesco, Did we have any OOB feature ?
Above steps for custom workflow or plugin?
Hi Tin ,
proceed as follows:
1) retrieve all contacts, selecting only emailaddress1
2) setup a string list, we name "EmailAddressList"
3) loop all records
4) for each record, check if emailaddress1 exists into EmailAddressList.
5) If not, add it to list
6) If exists, call a service.Delete over the current contact record
Please let me know if you solve.
If you found the answer helpful, please mark as Verified
Join my network on LinkedIn Follow me on Twitter
Thank You & Best Regards
Francesco Picchi
Microsoft Dynamics CRM Consultant, Bologna+Milano, ITALY
Independent Contractor
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,214 Most Valuable Professional
nmaenpaa 101,156