Goca
Goca

Reputation: 1893

QualifyLeadRequest triggers duplicate detection in CRM 2015

I'm running in to a problem when trying to qualify a lead using QualifyLeadRequest. I get an error saying:

A record was not created or updated because a duplicate of the current record already exists.

The issue is that I have a Duplicate Detection Rule that is getting triggered when qualifying the lead from my custom plugin and this should not happen because in "CRM Settings -> Data Management -> Duplicate Detection Settings" it is set to "During data import" only.

I know that duplicate detection is being triggered because if I disable the custom rule then everything works.

Is QualifyLeadRequest ignoring the settings?

Do I have to set this manually before qualifying the lead from my plugin?

This is the code I have:

     var qualifyLeadRequest = new QualifyLeadRequest
        {
            CreateAccount = false,
            CreateContact = true,
            LeadId = lead,
            Status = new OptionSetValue(3)
        };

 var response = (QualifyLeadResponse)context.Execute(qualifyLeadRequest);

Upvotes: 2

Views: 1591

Answers (1)

Goca
Goca

Reputation: 1893

I manage to solve my problem by explicitly disabling the duplicate detection during the request:

  //Disable DuplicateDetection
  qualifyLeadRequest.Parameters.Add("SuppressDuplicateDetection", true);

After a lot of testing using fiddler I noticed that this parameter was been set to false during the request, changing this to true fix the problem and duplicate detection stop being triggered.

Not sure if is a bug or works as designed but ignoring the duplicate detection settings is a bad idea.

I hope this can help someone else with similar problems.

Upvotes: 2

Related Questions