Apex Plugin - Typed

Last published at: 2022-02-11 14:33:24 UTC
Delete

Duplicate Check's Apex Plugins are only available in the Premium edition.

You can use the APEX PLUGINS to extend duplicate check functionalities with your own customizations. You need to enable these plugins via the DC Settings page.

Search Plugin

The Search Plugin will provide you with the search results every time a search is executed via Duplicate Check.

InterfaceSearch

You need to create an Apex Class which implements the Duplicate Check Search Interface. All methods should be implemented. Please see below for an example.

global class DefaultSearch implements dupcheck.dc3Plugin.InterfaceSearch {
   global void processResults(String methodName, Id sourceId, Map<String, List<dc3SearchResult>> searchResults) {
      // YOUR CUSTOM CODE
      return;
   }
}

processResults
methodName - contains a value which indicated where the Search is started from.
sourceId - contains the record Id if the search was started for a specific record.
searchResults - contains the search results for the particular search. See the Apex API for the class definition.

Prevention Plugin

The prevention plugin allows you to execute custom apex code whenever a record is created or updated. The result of this custom apex code gives you a status of the updated or created record. This status will be UNIQUE, DUPLICATE, DELTA, WEB2LEAD, DIRECT.

InterfacePrevention

You need to create an Apex Class which implements the Duplicate Check Prevention Interface. All methods should be implemented. Please see below for an example.

 global class DefaultPrevention implements dupcheck.dc3Plugin.InterfacePrevention {
   global void processStatus(Set < Id > recordIdSet, dc3Plugin.PreventionStatus status) {
      // YOUR CUSTOM CODE
      return;
   }
}

processStatus
recordIdSet - are the records which should receive this status.
status - is the status which is given to the records.

Merge Plugin

The merge plugin allows you to execute custom apex code before or after the merge is done or when the merge has failed. Implementation of this plugin consists of two steps; Implementation of the Apex Interface and enabling the implemented interface in the DC Setup.

InterfaceMerge

You need to create an Apex Class which implements the Duplicate Check Merge Interface. All methods should be implemented. Please see below for an example.

global class DefaultMerge implements dupcheck.dc3Plugin.InterfaceMerge {


   global void beforeMerge(String objectPrefix, Sobject masterRecord, List < sobject > mergedRecordList) {
      // YOUR CUSTOM CODE
      return;
   }


   global void mergeFailed(String objectPrefix, Sobject masterRecord, Set < id > mergedRecordsIds, dupcheck.dc3Exception.MergeException exceptionData) {
      // YOUR CUSTOM CODE
      return;
   }


   global void afterMerge(String objectPrefix, Sobject masterRecord, Set < id > mergedRecordIds) {
      // YOUR CUSTOM CODE
      return;
   }
}

beforeMerge
objectPrefix - is the object key prefix. for example '00Q' is the lead object.
masterRecord - is the master sobject which remains after the merge. This sobject contains the fields which will be updated on the master record upon merging.
mergedRecordList - is a list of Sobject. This lists correspond with the records which will be merged into the master record.

mergeFailed
objectPrefix - is the object key prefix. for example '00Q' is the lead object.
masterRecord - is the master sobject which should have remained after the merge. This sobject contains the fields which will be updated on the master record upon merging.
mergedRecordIds - is a set of ids. These ids correspond with the record which were planned to merge into the master record.
exceptionData is the salesforce exception thrown and the reason why the merge has failed.

afterMerge
objectPrefix - is the object key prefix. for example '00Q' is the lead object.
masterRecord - is the master sobject which remains after the merge. This sobject contains the fields which will be updated on the master record upon merging.
mergedRecordIds is a set of ids. - These ids correspond with the record which will be merged into the master record.

Convert Plugin

You need to create an Apex Class which implements the Duplicate Check Convert Interface. All methods should be implemented. Please see below for an example.

global class DefaultConvert implements dupcheck.dc3Plugin.InterfaceConvert {


   global void beforeConvert(Database.LeadConvert leadConvertData) {
      // YOUR CUSTOM CODE
      return;
   }


   global void convertFailed(Database.LeadConvert leadConvertData, dupcheck.dc3Exception.ConvertException exceptionData) {
      // YOUR CUSTOM CODE
      return;
   }


   global void afterConvert(Database.LeadConvertResult leadConvertResult, Task taskData) {
      // YOUR CUSTOM CODE
      return;
   }
}

beforeConvert
leadConvertData - Contains all the lead conversion information. Definition and methods can be found via Salesforce Help.

convertFailed
leadConvertData - Contains all the lead conversion information. Definition and methods can be found via Salesforce Help.
exceptionData - The salesforce exception thrown and the reason why the convert has failed.

afterConvert
leadConvertResult - Contains the result of the lead conversion. Definition and methods can be found via Salesforce Help.
taskData - If a task is created upon conversion this contains the task.