Classifier API

Simon Maskell Updated by Simon Maskell

This feature is available on the Advanced & Ultimate Tiers. Learn more

The DE Apex API includes methods to classify records, useful for when you want to re-classify records at a later point in their lifecycle, as classification will automatically take place on record creation. It could also be used if you don't want to perform classification on initial insert of the record.

Classify Records

global static ClassifierResultDTO classifyRecords(ClassifierRequestDTO request)

Perform the requested classification on a given list of records, the request is of type ClassifierRequestDTO and returns an object of type ClassifierResultDTO. The request can include what classifications are to be performed on the records, those classifications needs to be configured but don't have to be enabled. The result includes whether the request failed validation and why, and if successful, contains the status of individual record classifications.

Example

Perform territory and custom classification on some leads.

List<Id> leadIds = new List<Id>();// List of lead ids to process
List<String> classificationTypes = new List<String>{ 'Territory', 'CustomClassification' };
n2de.ClassifierRequestDTO classifierRequest = new n2de.ClassifierRequestDTO(leadIds, 'Lead', classificationTypes, null);

n2de.ClassifierResultDTO classifierResponse = n2de.GlobalAPIClassifier.classifyRecords(classifierRequest);

if (!classifierResponse.validationSuccess) {
System.debug('Validation failed: ' + classifierResponse.validationError);
} else {
for (n2de.ClassifierIndividualResultDTO result : classifierResponse.recordResults) {
if (result.classificationStatus == 'Missing' || result.classificationStatus == 'Error') {
System.debug('Classification failed: ' + result.classificationError);
}
}
}
  • The list of record ids need to be populated
  • The object type needs to be populated
  • The list of classification types needs to be populated, be configured and be valid for the object type
    • The valid types are "Territory", "Match", "CustomClassification" and "AutoConversion"
  • If custom classification is included, the optional stamp groups to use can be populated, but must not be empty

Bulk Classify Records

global static List<ClassifierResultDTO> bulkClassifyRecords(List<ClassifierRequestDTO> requests)

Perform the requested groups of classification on the given list of records, the request is a list of type ClassifierRequestDTO and returns a list of type ClassifierResultDTO. The requests can include what classifications are to be performed on the records, those classifications needs to be configured but don't have to be enabled. The result includes whether the request failed validation and why, and if successful, contains the status of individual record classifications. This API allows you to perform different classifications on different objects, at the same time.

Example

Perform territory classification on some leads and custom classification for a stamp group on some accounts.

List<Id> leadIds = new List<Id>();// List of lead ids to process
n2de.ClassifierRequestDTO classifierRequestLead = new n2de.ClassifierRequestDTO(leadIds, 'Lead', new List<String>{ 'Territory' }, null);
List<Id> accountIds = new List<Id>();// List of account ids to process
n2de.ClassifierRequestDTO classifierRequestAccount = new n2de.ClassifierRequestDTO(accountIds, 'Account', new List<String>{ 'CustomClassification' }, new List<String>{ 'Stamp Group A'} );

List<n2de.ClassifierResultDTO> classifierResponses = n2de.GlobalAPIClassifier.bulkClassifyRecords(new List<n2de.ClassifierRequestDTO>{ classifierRequestLead, classifierRequestAccount });

for (n2de.ClassifierResultDTO classifierResponse : classifierResponses) {
if (!classifierResponse.validationSuccess) {
System.debug('Validation failed: ' + classifierResponse.validationError);
} else {
for (n2de.ClassifierIndividualResultDTO result : classifierResponse.recordResults) {
if (result.classificationStatus == 'Missing' || result.classificationStatus == 'Error') {
System.debug('Classification failed: ' + result.classificationError);
}
}
}
}
  • The list of record ids need to be populated
  • The object type needs to be populated
  • The list of classification types needs to be populated, be configured and be valid for the object type
    • The valid types are "Territory", "Match", "CustomClassification" and "AutoConversion"
  • If custom classification is included, the optional stamp groups to use can be populated, but must not be empty
This method is also available to use within a Salesforce Flow under the name "DE Classify Records" in the category "Distribution Engine". An example of using it can be found in the Classify on Address Change article.

How did we do?

Classifier API Parameters

Contact