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

TypeVariableDescription
SObjectrecordAThe first record to compare.
SObjectrecordBThe second record to compare.
Set<Id>scenarioIdsA 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 and recordB must be queried to include (system) fields required for matching.

Output

  • The method returns an Integer representing the similarity score between recordA and recordB

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);