0

I use Rest API to create a bunch of records users key in.

Sometimes, the subscriber orgs have duplicate rules enabled for the sObjects we use, and since the DuplicateRuleHeader is missing from REST API the save simply fails.

Since i do not want to create a custom Apex Rest endpoint just to create sObjects, is it possible given a sObject type to find out if duplicate management is enabled for it?

Update I can't use an actual sObject for this, at the decision point all i have is my sObject.sObjectType

Update 2 My users don't have View Setup and Configuration permission so they can't query DuplicateRule sObject

3
  • Are you talking about this? This is metadata API, which had details about metadata - developer.salesforce.com/docs/atlas.en-us.api_meta.meta/…
    – Ysr Shk
    Jul 16 '20 at 3:32
  • @YsrShk No, i am not talking about Metadata API. As a normal user (non admin) they won't have access to it. This is for normal API, to detect somehow whether these rules are even enabled so we can try to avoid the issue.
    – zaitsman
    Jul 16 '20 at 3:46
  • @identigral i wish, sadly that requires me to actually submit a findDuplicates but my question says given a sObject type not 'if i had a sObject'
    – zaitsman
    Jul 16 '20 at 5:46
1

You can query DuplicateRule object via SOQL:

SELECT Id, DeveloperName,MasterLabel FROM DuplicateRule WHERE sObjectType = 'Contact' AND isActive = true

will return 1 or more rows if the rule is active for this sObject type.

1
  • I REALLY like this approach. The problem is, without 'View Setup and Configuration' permission, i am getting sObject type 'DuplicateRule' is not supported.
    – zaitsman
    Jul 16 '20 at 23:51

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.