Hi Rachel
You can create duplicate detection rules for the related entity. CRM will find your duplicate data's , popup a screen but even find the duplicate data , user can save the record.
Below request will return duplicate records related Duplicate Detection Rule .
** Be careful if CRM does not have a Duplicate Detection Rule for related entity , this request throws an error..
Entity DuplicateEntity = new Entity("entitylogicalname");
DuplicateEntity["fieldname"] = Value;
var request = new RetrieveDuplicatesRequest
{
BusinessEntity = DuplicateEntity,
MatchingEntityName = DuplicateEntity.LogicalName,
};
RetrieveDuplicatesResponse res = (RetrieveDuplicatesResponse)_service.Execute(request);
if (res.DuplicateCollection.Entities.Count > 0)
{
//duplicate found
}
If you find this post helpful then please Vote as Helpful and Mark As Answer. Thanks and Regards, Polat Aydın
My blog