Salesforce Decode
Salesforcedecode
Back to questions
ApexAdvanceddeduplicationhashdata-quality

Implement custom hash and deduplication logic in Apex

Real World Scenario

Lead import creates duplicates despite duplicate rules because vendor normalizes company names differently.

Expected Answer

• Generate Hash__c from normalized company+email key in before insert • Unique index on Hash__c blocking duplicate insert • Normalization utility lower trim remove punctuation • Batch merge job for existing duplicates found by hash collision report • Override hash for legitimate same-name different entity cases • Log near-matches below hash threshold for steward review • Integration sends external dedup key preferred over computed hash

Follow-Up Questions & Answers

Click to expand — each follow-up includes a direct, interview-ready answer

Main difference: use case and scale. Generate Hash__c from normalized company+email key in before insert. Unique index on Hash__c blocking duplicate insert. Pick based on your integration pattern and team capability. Dedup belongs in multiple layers—Apex hash catches what fuzzy duplicate rules miss. Optimize for scale and operational observability.

Architect Perspective

Dedup belongs in multiple layers—Apex hash catches what fuzzy duplicate rules miss.