Start a Plauti deduplicate job from Apex

The startDCJob process is designed to initiate a Deduplicate Job from Apex. It creates a DC Job record, optionally applies filters for duplicate criteria, and then starts the batch process to search for duplicates. The process also updates the job definition with the Apex job identifier for tracking purposes.

This process works best when integrated into a duplicate management strategy, ensuring that duplicate records are identified systematically and handled for data quality purposes.

Key Points

  • Creates a dupcheck__dcJob__c record with required fields.
  • Optionally supports adding a filter through the dupcheck__filterWith__c, dupcheck__filterOn__c, and dupcheck__filter__c fields.
  • Inserts the job definition, then executes a batch process using dupcheck.dc3SearchBatch with a specified batch size.
  • Updates the DC Job record with the Apex job ID to correlate the job definition with the batch process, ensuring traceability.
FieldTypeDescription
dupcheck__name__cStringA custom name for the DC Job, serving as a label to identify the duplicate check job.
dupcheck__type__cStringMust be set to 'search', indicating that this job performs a duplicate search operation.
dupcheck__sourceObject__cStringThe ID of the source object whose records will be checked for duplicates.
dupcheck__matchObject__cStringThe ID of the match object used to compare and identify duplicate records. For a cross-object job, make sure the source and match object are different.
dupcheck__status__cStringThe initial status of the job, set to 'Holding', which indicates that the job is prepared for processing. Do not change this.
dupcheck__scenario__cStringA comma-separated list of scenario IDs that define the duplicate matching criteria.

Apex Example

// Create a new DC Job record for duplicate checking
dupcheck__dcJob__c jobData = new dupcheck__dcJob__c(
    dupcheck__name__c = 'My Apex DC Job', // Your custom job name
    dupcheck__type__c = 'search',         // Constant value (do not change)
    dupcheck__sourceObject__c = '001',      // The source object ID to be checked for duplicates
    dupcheck__matchObject__c = '001',       // The match object ID used for duplicate matching
    dupcheck__status__c = 'Holding',        // Initial status; do not change
    dupcheck__filterOn__c = null,           // Default value; do not change
    dupcheck__scenario__c = 'a0P17000005cSNgEAM' // Comma-separated list of scenario IDs
);

// Optional: Apply a filter if needed
/*
jobData.dupcheck__filterWith__c = 'all';
jobData.dupcheck__filterOn__c = 'filter';
jobData.dupcheck__filter__c = '(BillingCountry = \'nl\')';
*/

// Insert the job definition
insert jobData;

// Start the batch process to search for duplicates with a batch size of 5
Id apexJobId = Database.executeBatch(new dupcheck.dc3SearchBatch(jobData.Id), 5);

// Update the DC Job record with the Apex job ID for tracking purposes
update new dupcheck__dcJob__c(Id = jobData.Id, dupcheck__apex__c = apexJobId);