الثلاثاء، 9 فبراير 2016

CRM 2013:Check record duplicate detection Using C# .

 Entity Account= new Entity("account");
            Account["name"] = "Test Account";
            Account["accountnumber"] = "111111111";

Microsoft.Crm.Sdk.Messages.RetrieveDuplicatesRequest req = new Microsoft.Crm.Sdk.Messages.RetrieveDuplicatesRequest
                {
                    BusinessEntity = Account,
                    MatchingEntityName = "account",
                    PagingInfo = new PagingInfo() { PageNumber = 1, Count = 50 }
                };

                Microsoft.Crm.Sdk.Messages.RetrieveDuplicatesResponse resp = (Microsoft.Crm.Sdk.Messages.RetrieveDuplicatesResponse)Service.Execute(req);

                if (resp.DuplicateCollection.Entities.Count > 0)
                    continue;