You need to sign in to do that
Don't have an account?

Use Matching Rules in Apex to find all leads which match an account
Salesforce has a Matched Leads Component that can be placed on an account to show which leads match the account.
The problem is that the layout is not conducive to the work that my company needs to do and I need to create a custom component which uses the same matching logic but displays in a more traditional table format.
I cannot find any documentation on where to start on how to utilize the matching rules engine in Apex code to get a list of leads that I can then manipulate into our needed format.

The problem is that the layout is not conducive to the work that my company needs to do and I need to create a custom component which uses the same matching logic but displays in a more traditional table format.
I cannot find any documentation on where to start on how to utilize the matching rules engine in Apex code to get a list of leads that I can then manipulate into our needed format.
Greetings!
There is a pre-defined class which can help you to get the records by matching rule.Please find the below thread for more information.
https://salesforce.stackexchange.com/questions/163619/accessing-a-duplicate-rules-matching-rules-via-apex
Kindly mark it as best answer if it helps so that it can help others in the future.
Warm Regards,
Shirisha Pathuri
Still struggling with how to handle these in Apex.
I see the classes exist, but what's the order of operations to go from having an account ID to actually getting a list of leads?
Little late to the party, but I was looking into this and I found this article:
https://idealistconsulting.com/blog/6-tips-duplicate-management-apex
What you could do is instantiate a new List of Leads in Apex using the Account data. Fill in the fields that will be used in the matching rule (i.e, lead.company = account.name, lead.phone = account.phone, etc..)
Then use:
List<Datacloud.FindDuplicatesResult> results = Datacloud.FindDuplicates.findDuplicates(List<Lead>) which seems to use existing matching rules to return duplicates (if found), You can then parse your lead list, compare against the results and determine for each lead
if matches were found & how many and which records.
I havent tested it out but I plan on implementing it soon for a project.
Hope that helps.