For the complete documentation index, see llms.txt. This page is also available as Markdown.

How can I detect what record is the Master

Learn how to retrieve the surviving master record ID before updating and merging duplicate pairs using Delpha's Apex API.

When managing duplicate records, you often need a programmatic way to evaluate a pair of duplicates and determine which record should be preserved (the "Master") and which should be archived or deleted.

Depending on your use case, you can evaluate a single pair of duplicates or process them in bulk.

1. Single Record Processing

Overview: If you are only evaluating a single duplicate pair at a time, you can use the delpha.DDQ_DuplicateApi.getMaster() method to determine which record will serve as the master (surviving) record prior to updating pair members and completing a duplicate merge.

Method Overview

The function evaluates two duplicate records against your configured Delpha selection rules to identify the primary master record.

Function Signature

Id masterRecordId = delpha.DDQ_DuplicateApi.getMaster(
    '[RecordId1]', 
    '[RecordId2]', 
    '[DuplicateSettingId]'
);

Parameters

Parameter

Type

Description

RecordId1

String / Id

Salesforce Record ID of the first duplicate.

RecordId2

String / Id

Salesforce Record ID of the second duplicate.

DuplicateSettingId

String / Id

The ID of the Delpha Duplicate Setting containing your selection rules.

Output: Returns the Id of the master record.

Step-by-Step Implementation Guide

Step 1: Select Duplicate Records

Query the duplicate pairs that require processing. This step is required when preparing records for bulk processing.

Step 2: Retrieve the Duplicate Setting ID

  1. Navigate to the Delpha Setup app in Salesforce.

  2. Open the Duplicate Setting rule you wish to apply.

  3. Copy the Record ID directly from the browser URL.

Step 3: Execute getMaster

Call delpha.DDQ_DuplicateApi.getMaster() passing delpha__RecordId__c, delpha__MatchedRecordId__c, and your DuplicateSettingId.

2. Bulk Record Processing

When processing large volumes of duplicate records (for example, in a Scheduled Batch Apex job), you can resolve multiple pairs at once using a bulkified method.

Method Overview: resolve()

Evaluates a list of duplicate pairs and determines the winning master record for each pair in a single bulkified operation.

Signature

Parameters

Parameter

Type

Required

Description

pairs

List<delpha__DDQ_DuplicateRecord__c>

Yes

List of duplicate pair SObjects to evaluate. Every record in the list must have all required fields explicitly queried in SOQL beforehand.

Return Value

Return Type

Description

Map<Id, Resolution>

A map where each key corresponds to a duplicate pair record Id (delpha__DDQ_DuplicateRecord__c.Id), and the value is a Resolution object containing the master record determination result.

Key Behaviors & Exceptions

  • No Automatic Field Check: The method assumes all required fields are loaded. Omitting any required field from the input records will throw an unhandled System.SObjectException.

  • No Internal DML or Logging: This method is purely evaluative—it returns calculation results and does not update records in the database or generate error logs internally.

  • 1:1 Mapping: Output guarantees exactly one Resolution entry per distinct duplicate pair ID passed in the pairs list.

Step by Step implementation Guide

Prerequisites

To execute this, you will use custom local Apex classes deployed in your Salesforce org to process the duplicate pairs generated by the Delpha managed package.

  • delpha__DDQ_DuplicateRecord__c: The custom object provided by the Delpha package.

  • DuplicateResolver and Resolution: Custom local Apex classes (not provided by Delpha) used to process Delpha's data and return the designated master record.

Code Example

Below is the standard snippet to retrieve unhandled duplicate pairs and resolve them in bulk.

Important Technical Considerations

  • Required Fields

Field API Name

Data Type

Description

Id

Id

The unique Salesforce Record ID of the delpha__DDQ_DuplicateRecord__c duplicate pair record.

delpha__RecordId__c

Id (Lookup)

The Salesforce Record ID of the primary record in the duplicate pair.

delpha__MatchedRecordId__c

Id (Lookup)

The Salesforce Record ID of the matched candidate record in the duplicate pair.

delpha__IsCrossRecord__c

Boolean

Indicates whether the match is across different SObject types (e.g., Lead vs. Contact) or within the same object type.

delpha__DuplicateSettings__c

Id (Lookup)

The ID of the specific Delpha duplicate setting rules/configuration applied to evaluate this pair.

  • The Resolution Map The custom method returns a Map<Id, Resolution> where the key is the ID of the delpha__DDQ_DuplicateRecord__c pair, and the value is a Resolution object containing the Master ID.

  • Next Steps The provided code evaluates the data, but does not execute any Database changes. You must replace the System.debug() line with your own Database operations (such as Database.merge or updating status fields) based on your business requirements.

Last updated

Was this helpful?