2

I have a requirement where we need to prevent Duplicate Contacts. The criteria should be based on First Name, last Name and Account id. I am trying to implement 'Duplicate management' functionality.

Account is related to Contact on a Look up relationship. Account Name is available in Standard Fields list and we enter it in UI. But Account Id is not available in Standard Field list. So it's not available to pick when I create 'Duplicate Rules'. But it's available to pick in 'Validation Rules', I am not sure how. Does anyone has any idea on this?

1

Solution 1

Use a duplicate rule on Account to prevent duplicate Account Names, Then, your duplicate rule on Contact can use FirstName, LastName, Account Name

Solution 2 (if duplicate account names are OK)

Matching rules can't use formula fields so you'll need a custom field on Contact of type Text: AccountId__c

Populate AccountId__c with a before insert/update trigger. Note that duplicate rules do not run after workflow field updates so you need a trigger here.

Then, your matching rule can use First Name, Last Name, and AccountId__c

6
  • Thank you for the reply. But yes Account Names can be duplicate since unique key is combination of Name and Symbol. So if I go as per your 2nd solution, are you sure triggers will be fired before Duplicate Rules? – Amulya Mar 23 '16 at 17:43
  • The second solution works as I wanted. Thanks again. – Amulya Mar 23 '16 at 19:36
  • 1
    Triggers are definitely fired before duplicate rules; as a kindness to the Community, mark the answer as the solution or, if it is not the solution, indicate why not in a comment. – cropredy Mar 23 '16 at 19:57
  • 1
    This is really a new question and should be posed as such but why not Data Loader? – cropredy Apr 6 '16 at 19:36
  • 1
    Thanks, i was thinking to use simple SOQL query to do that but in Production need to go for Batch apex or something. But yeah Data Loader is only best option. – Amulya Apr 8 '16 at 14:09

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.