Input & Output

Merge records (List of SObjects)

The doMerge method merges multiple Salesforce records into a single master record, following the rules defined in the Plauti Deduplicate Merge Rules. It returns a boolean to indicate success or failure.

Method Signature

Method Name: doMerge

Boolean doMerge(List<SObject> objectList)

Parameters

TypeVariableDescription
List<SObject>objectListA list of Salesforce objects representing the input.

📘

Ensure that all fields with custom merge rules (i.e., rules other than “Master Record Rule”) are included in the query performed within the doMerge method. The doMerge method relies on these fields to apply the defined custom merge rules. If required fields are missing in the data processed by doMerge, the method will fail, as it cannot execute the custom merge logic without the necessary field values.

Output

  • true: The merge was successful.
  • false: The merge failed.

Apex example

This snippet retrieves a list of duplicate Contact records, initializes the Duplicate Check API, and attempts to merge them using the doMerge method. It logs the queried contacts, starts the merge process, and outputs whether the merge was successful or not.

// Query the records you want to merge
List<Contact> duplicateContacts = [
    SELECT Id, Name, Email, LastModifiedDate
    FROM Contact
    WHERE Id IN ('003J8000007jigQIAQ', '003J8000007jigRIAQ')
];
System.debug('Queried duplicate contacts: ' + duplicateContacts);

// Initialize the Duplicate Check API
dupcheck.dc3Api dc3Api = new dupcheck.dc3Api();
System.debug('Duplicate Check API initialized.');

// Execute the merge using the Duplicate Check API
System.debug('Executing merge operation for duplicate contacts...');
Boolean isMerged = dc3Api.doMerge(duplicateContacts);
System.debug('Merge operation completed. Merge result: ' + isMerged);

// Output result with conditional feedback
if (isMerged) {
    System.debug('Merge was successful.');
    // Add any post-merge actions here if required
} else {
    System.debug('Merge failed.');
}