Input & Output
Calculate matching score with predefined scenario
The matchRecord(SObject recordA, SObject recordB, Set<Id> scenarioIds)
method evaluates the similarity between two Salesforce records based on specific Plauti Deduplicate scenarios. It uses the provided records and scenarios to calculate a matching score, which indicates how closely the records align.
Method Signature
Method Name: matchRecord
static Integer matchRecord(SObject recordA, SObject recordB, Set<Id> scenarioIds)
Parameters
Type | Variable | Description |
---|---|---|
SObject | recordA | The first record to compare. |
SObject | recordB | The second record to compare. |
Set<Id> | scenarioIds | A set of scenario IDs defining the rules for comparison. |
- The records must belong to the same Salesforce object type (e.g.,
Contact
,Account
). - Both
recordA
andrecordB
must be queried to include (system) fields required for matching.
Output
- The method returns an
Integer
representing the similarity score betweenrecordA
andrecordB
Apex Example
This snippet retrieves two Contact records, logs their details, and defines a set of scenario IDs for matching. It then executes the matchRecord
method from the Plauti Deduplicate API to compare the two records and logs the resulting matching score.
// Query the records to match
Contact recordA = [SELECT FirstName, LastName, Email FROM Contact WHERE Id = '003J800000A3JluIAF'];
System.debug('Record A retrieved: ' + recordA);
Contact recordB = [SELECT FirstName, LastName, Email FROM Contact WHERE Id = '003J800000A3JlkAAF'];
System.debug('Record B retrieved: ' + recordB);
// Define the set of scenario IDs
Set<Id> scenarioIds = new Set<Id>{'a2B3x0000008Abc', 'a2B3x0000008Xyz'};
System.debug('Scenario IDs being used for matching: ' + scenarioIds);
// Execute the matchRecord method
Integer matchingScore = dupcheck.dc3Api.matchRecord(recordA, recordB);
System.debug('Matching Score between recordA and recordB: ' + matchingScore);
Updated 17 days ago