Using the Merge Set Master Plugin

Set Master record in Merge

This article explains how to extend Plauti Deduplicate merge functionality by implementing the Merge Set Master Plugin. You can use this interface to override the default master record selection by specifying, via code, which record should become the master during a merge operation.

Overview

The Merge Set Master Plugin lets you programmatically determine which record should serve as the master during a merge operation. The plugin receives as input all candidate records along with the default master record ID chosen by the Merge Rules. By implementing this interface, you can override the default selection—for instance, by selecting the record that meets a specific condition (such as having a particular field value).

In manual merge scenarios, the Merge Set Master Plugin is triggered after the merge process starts but before the manual merge interface is shown. This means that even if your custom logic selects a master record, the user still has the option to override that decision during a manual merge. If you wish to prevent any user override, you can disable master selection in the Merge Rules or enforce your custom master selection logic in the BeforeMerge method.

Implementation

To implement the Merge Set Master Plugin, create an Apex class that implements the dupcheck.dc3Plugin.InterfaceMerge interface. The Merge Set Master and Merge Set Field functionality must be executed within the Generic Plugin. The primary method to implement is:

mergeSetMaster(dupcheck.dc3PluginModel.MergeSetMasterInput input)
Step 1. Create Apex Class

Ensure your class is declared as global so that it can be referenced by the Plauti Deduplicate framework.

Step 2. Implement Merge Set Master Logic
  • objectPrefix: The 3-character identifier that denotes the record type (for example, '00Q' for Leads).
  • objectDataList: A collection of candidate records that are eligible to be merged.
  • The default master record ID is provided based on standard DC Merge Rules.
  • Logic: For example, your custom logic queries the number of related opportunities for each candidate record. The record with the highest number of related opportunities is chosen as the master record because it represents the most active or valuable lead.

Step 3. Reference the Plugin in DC Settings

In your Salesforce org, navigate to the Deduplicate Setup page, then open the DC Settings section.



Under the "Generic Plugin" field, enter the name of your custom Apex class (e.g., DefaultGenericPlugin) This registration ensures that the Plauti Deduplicate framework uses your custom logic during merge operations.

Merge Flow

flowchart TB
    A([Merge is initiated]) --> B[Merge Rules]
    B --> C[**Set Master Plugin**]
    C --> D[Set Field Plugin]
    D --> E{Manual Merge?}
    E -- "Yes" --> F[Merge page invoked - User can override Merge Rules, Set Master and Set Field Plugin]
    F --> G([User Clicks Merge])
    G --> H[Invoke BeforeMerge]
    E -- "No" --> H
    H --> I[MERGE EXECUTED]
    I --> J{Merge Successful?}
    J -- "Yes" --> K[Invoke AfterMerge]
    J -- "No" --> L[Invoke MergeFailed]
    K --> M
    L --> M[Merge Process Completed]