Examples & Use Cases
Prevention Plugin
Below are example implementations of the Duplicate Check Prevention Plugin, each demonstrating a different business use case.
Basic Example Code
global class DefaultPrevention implements dupcheck.dc3Plugin.InterfacePrevention {
global void processStatus(Set<Id> recordIdSet, dc3Plugin.PreventionStatus status) {
// YOUR CUSTOM CODE
// Log basic metadata
System.debug('Prevention Plugin executed with status: ' + status);
System.debug('Record(s) being processed: ' + recordIdSet);
// Additional custom logic can be added here based on the status.
// For example, you could branch your logic as follows:
/*
if (status == dc3Plugin.PreventionStatus.DUPLICATE) {
// Execute logic specific to duplicate detection.
} else if (status == dc3Plugin.PreventionStatus.UNIQUE) {
// Execute logic for unique records.
}
*/
return;
}
}
Example 1: Record Reassignment Prevention Plugin
This example demonstrates a use case where, if the Prevention Plugin determines that a record's status is DUPLICATE, the record ownership is changed to a designated queue. This ensures that the record is not assigned to a sales representative, but instead is routed to a review queue for further processing.
global class RecordReassignmentPreventionPlugin implements dupcheck.dc3Plugin.InterfacePrevention {
global void processStatus(Set<Id> recordIdSet, dc3Plugin.PreventionStatus status) {
// Proceed only if the status is DUPLICATE
if (status == dc3Plugin.PreventionStatus.DUPLICATE) {
// Query the records (assumed to be Leads in this example)
List<Lead> leadsToUpdate = [SELECT Id, OwnerId FROM Lead WHERE Id IN :recordIdSet];
// Set the new owner ID to a specific queue
Id queueId = '00GXXXXXXXXXXXX';
// Update the owner of each Lead record to the queue
for (Lead l : leadsToUpdate) {
l.OwnerId = queueId;
}
try {
update leadsToUpdate;
System.debug('Records reassigned to queue for review: ' + recordIdSet);
} catch (DmlException e) {
System.debug(LoggingLevel.ERROR, 'Error reassigning records: ' + e.getMessage());
}
}
return;
}
}
Updated 17 days ago