We have a scenario where we want to prevent users from creating duplicate contacts but want to allow users to be able to create the same contact with same details if its on a different account.
What I have done is created a flow so that it updates the field (Associated_Account__c) before it is saved. My flow will checks if the contact has an account associated
If it does it will add the account id to it
if it doesn't it will add 'No account'.
On my duplicate matching rule I have these conditions set
Email(exact match) phone (fuzzy match) Associated Account__c (exact match)
The idea behind this idea is if there are no accounts attached to it they should have 'No Account' and if the phone and email are the same the duplicate rule will flag it and prevent users from creating it.
If there is an account attached to it and because every account has a unique id they should be able to create the contact.
My problem Im having is when i test and try and create the same contacts without an account attached to it the duplicate rule doesn't fire. I am assuming because the field isn't being updated by the flow even though i have it set to update before saving the record.
Am I going about this the correct way or should I have a different approach? I would like to try and code this but I dont know how.
If its simple I would like to have a crack at it.