Using the Direct Processing Plugin

Direct Processing Plugin

This article explains how to extend Duplicate Check's direct processing functionality by implementing the Direct Processing Plugin interface. You can use this interface to run custom logic before the system automatically merges or converts duplicate records—based on the context provided by the system.

Overview

The Direct Processing Plugin interface allows you to insert custom logic into the duplicate record direct processing flow. The trigger is a direct processing event initiated when records are created or updated via automation channels (such as API Insert, Web-to-Lead, Flow, etc.). By implementing this interface, you can tailor the actions that occur:

  • Before Direct Processing:
    Evaluate duplicate search results and decide whether to proceed with a merge or conversion, or halt processing for manual review.

  • Modify Processing Decisions:
    Adjust flags (for example, doConvert or doMerge) or modify the set of duplicate search results before automated actions are executed.

  • Store or Log Results:
    Stop the automatic processing and simply store the result for later analysis or manual intervention.


flowchart TD
    A[Record Created/Updated via API] --> B[Duplicate Search Executed]
    B --> C[Invoke DIRECT_PROCESS_BEFORE Plugin]
    C --> D{Custom Logic Decision}
    D -- Proceed with Convert/Merge --> E[Automatic Processing]
    D -- Halt Processing --> F[Optionally Store/Log Result for Manual Action]
    E --> G[Direct Processing Completed]
    F --> G

Implementation

To implement the Direct Processing Plugin, create an Apex class that implements the dupcheck.dc3PluginInterface.

global Boolean isAvailable(dupcheck.dc3Plugin.PluginEventType eventType)
global Object execute(dupcheck.dc3Plugin.PluginEventType eventType, Object eventData)
Step 1. Create Apex Class

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

Step 2. Implement `isAvailable` Method
  • eventType: The type of event triggering the plugin (for example, DIRECT_PROCESS_BEFORE).
  • Return true if your plugin should handle that event.
Step 3. Implement `execute` Method
  • eventType: The event that triggered the plugin.
  • eventData: An instance of dupcheck.dc3PluginModel.DirectProcessBeforeInput containing:

    • The processing flags (doConvert and doMerge).
    • The incoming record (objectData).
    • The duplicate search results.
    • The feature or channel (e.g., onInsert, onFlow).
  • Route the event to your custom logic (for example, a helper method such as handleDirectProcessBefore).
Step 4. Implement Custom Logic
  • In your helper method (e.g., handleDirectProcessBefore), always query the record to retrieve the most up-to-date field values.
  • Based on your business rules, adjust the processing flags:

    • You can set doConvert and doMerge to false to halt processing or leave them true to continue.
  • Decide whether to store the processing result as a job by leaving storeAsJob at its default (true) or modifying it if needed.
  • Build and return a dupcheck.dc3PluginModel.DirectProcessBeforeOutput object that instructs the system how to proceed.
Step 5. Reference the Plugin in DC Settings

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

Under the "Direct Processing Plugin" field, enter the fully-qualified name of your custom Apex class (for example, YourCustomDirectProcessingPlugin). This registration ensures that the Duplicate Check framework uses your implementation during direct processing events.