I was inserting contact in Salesforce, before inserting contact I usually check if that contact exists in Salesforce or not by the email, If I found the 0 records with this email in Salesforce then I insert it else get the ID of that contact and update it.

But now the issue is that I don't have records with this email in the Contact, so I was getting the response:

[0] => stdClass Object
        [message] => Use one of these records?
        [errorCode] => UNKNOWN_EXCEPTION
        [fields] => Array


So I don't get it, what is going this. So I try to create with same email manually via Salesforce dashboard, I get to know that I have Record with the same email address in Lead Object and that's why it is going to show issue like the duplicate record.

You can see the screen below screenshot: https://www.screencast.com/t/3wvQxnElq

So I don't get what is going?

What is the relationship between in Lead and Contacts? Why I was getting this error? How can I fix this?

Can anyone please help me with this.



The Lead and Contact in this scenario do not have a direct relationship. You have a Duplicate Rule and Matching Rules configured in your Salesforce org that match Contacts against Leads, and vice versa, to ensure duplicates aren't added in one object against the other.

While in the user interface duplicate warnings can be just that - warnings, that the user can override - via the API duplicate warnings block the operation.

You can add criteria to your Duplicate Rule so that it does not run on your integration user or whichever user your API client is connecting under.

If you want your duplicate rule to run only when specific conditions are met, enter the conditions.

For example, the rule runs only if a record is being created by a user with a certain profile or role. Or set a condition for the rule to run only if the record includes a specific country, state, or province.

Alternately, if your PHP Salesforce client is connecting over the SOAP API, you may be able to set a DuplicateRuleHeader to suppress the duplicate rule.

| improve this answer | |
  • Thanks @David-reed. So what are the drawbacks if I deactivate the rule which is in the Contact Object? – Baikare Sandeep Nov 13 '18 at 12:56
  • Well, if you deactivate the rule, it won't prevent duplicates anymore. That's up to you and your organization. There are ways you can deal with it though, as I mention above - like adding exclusion criteria or using a DuplicateRuleHeader. – David Reed Nov 13 '18 at 13:27
  • Yes, exactly. We can Deal through Header as well. Also, I was already checking via API for records already exist in contacts? If exist I do Update it else create it! I think it also works and contacts also not created multiple times(tested it). – Baikare Sandeep Nov 13 '18 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.