2

We want to analyse all our existing Accounts data for duplicates using standard SalesForce features.

Assuming the standard duplicate checks (with matching rules) only works when accounts are created or modified we decided to run through all our accounts and do some minor modification. We would expect this would generate lots of Duplicate Record Sets.

If we try this manually via the UI it works: edit an account (which we know is duplicated) and set some unused field to 'X' and you get a warning about the possible duplicates.

However, when we do this exact same modification with Apex we get neither warning nor error (all SaveResults have isSuccess=true) but the Accounts with duplicates are updated.

12:53:39.186 (186543706)|VALIDATION_PASS
12:53:39.186 (186561366)|CODE_UNIT_FINISHED|Validation:Account:001D000000rXV8n
12:53:39.187 (187373834)|CODE_UNIT_STARTED|[EXTERNAL]|DuplicateDetector
12:53:39.187 (187388018)|DUPLICATE_DETECTION_BEGIN
12:53:39.188 (188132563)|DUPLICATE_DETECTION_RULE_INVOCATION|DuplicateRuleId:0BmL0000000CaWb|DuplicateRuleName:Standard|DmlType:UPDATE
12:53:39.249 (249565272)|DUPLICATE_DETECTION_END
12:53:39.249 (249633107)|CODE_UNIT_FINISHED|DuplicateDetector
12:53:39.299 (299935737)|CODE_UNIT_FINISHED|Account2SAP on Account trigger event AfterUpdate for [001D000000nbuy3, 001D000000rXV8n]
12:53:39.301 (301323703)|DML_END|[6]
12:53:39.301 (301863478)|USER_DEBUG|[12]|DEBUG|Database.SaveResult[getErrors=();getId=001D000000nbuy3IAA;isSuccess=true;]
12:53:39.301 (301945897)|USER_DEBUG|[12]|DEBUG|Database.SaveResult[getErrors=();getId=001D000000rXV8nIAG;isSuccess=true;]
12:53:39.302 (302012412)|USER_DEBUG|[44]|DEBUG|()

Setting Action On Edit to Block on Edit has no effect.

If there is a better way (without external Apps) of analysing dups please let us know.

  • Out of curiosity, is your Apex running with or without sharing, as in, what context is it running in? If running it as a sys admin, your privileges may be over-riding the dupe check. – crmprogdev Nov 27 '15 at 20:57
  • I'm using Execute Anonymous in Eclipse but a) I am selecting and getting both accounts and b) I'm an admin so the duplicates are "visible". – Marc Nov 30 '15 at 8:21
  • Are you sure the modifications in code are the same as those you tested from the UI? I just tested using Anonymous Apex and received the error message; neither the UI nor Apex cares if a field that is not used in a Matching Rule is updated, but will re-evaluation the matching rules if one of the relevant fields is updated, according to the documentation. (I ask, 2 years later...) – Brent Bow Mar 15 '17 at 5:04
  • I want to apply the matching rules retroactively without making real edits to records, as you do... trying to find a good way to do this without potentially editing important field values (even if they changes would be later reverted). Did you ever find a good way to do this, @Marc? – Brent Bow Mar 15 '17 at 5:05
  • Never found a way. Moved on from SF. – Marc Mar 15 '17 at 19:49

Your Answer

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

Browse other questions tagged or ask your own question.