About the Sample Application Duplicate Check Objects

The sample application includes the source code for two duplicate check objects that you can use as examples when writing your own object. In addition, the baseline Aptify installation includes two additional samples (one for Persons and one for Companies).

These duplicate check objects are described in the following sub-topics:

About the Customers Entity Duplicate Check Object

The Customers entity in the Motor Loaner application includes a plug-in that checks for duplicate customer records. The plug-in uses the spCheckForCustomerMatch Database Object to provide the following matching logic:

  • Existing records that match a new record's FirstName, LastName, PhoneAreaCode, and Phone are flagged as absolute matches.
  • Existing records that match a new record's FirstName and LastName (but not the phone number) are flagged as potential duplicates.

This stored procedure receives the RecordID, FirstName, LastName, PhoneAreaCode, and Phone to check from the CheckForDuplicate method (using the values from the current GE object), and it returns a Match Type and if a match is found, a list of matching IDs. This stored procedure returns one of the following Match Values:

  • 0: No duplicates found
  • 1: Absolute Match Found, the record ID(s) of the absolute match will be placed in the arDuplicates array
  • 2: Possible Match(s) found, the record ID(s) of the potential match(s) will be placed in the arDuplicates array

The text of the spCheckForCustomerMatch stored procedure appears below but you can also find it in the Database Objects service if you installed the sample application.

CREATE PROC spCheckForCustomerMatch 
                      (@SourceID INT,
                       @FirstName NVARCHAR(255),
                       @LastName NVARCHAR(255),
                       @Phone NVARCHAR(20),
                       @PhoneAreaCode NVARCHAR(20))
AS
SELECT MatchType, ID FROM 
(SELECT MatchType 
= CASE
       WHEN 
                      (FirstName = @FirstName AND
                       LastName = @LastName AND
                       Phone = @Phone AND
                       PhoneAreaCode = @PhoneAreaCode AND
                       ID <> @SourceID)
       THEN
                       1
       WHEN 
                      (FirstName = @FirstName AND
                       LastName = @LastName AND
                       ID <> @SourceID)
       THEN
                       2
       END,

ID FROM APTIFY..vwCustomers) CustomerMatch
WHERE MatchType IS NOT NULL 
 
OLD -- CREATE PROC spCheckForCustomerMatch 
                      (@SourceID INT,
                       @FirstName NVARCHAR(255),
                       @LastName NVARCHAR(255))
AS
SELECT MatchType, ID FROM 
(SELECT MatchType 
= CASE
       WHEN 
                      (FirstName = @FirstName AND
                       LastName = @LastName AND
                       ID <> @SourceID)
       THEN
                       2
       END,

ID FROM APTIFY..vwCustomers) CustomerMatch
WHERE MatchType IS NOT NULL

 

About the Vehicle Models Entity Duplication Check Object

This entity includes a plug-in that checks for duplicate vehicle models. This plug in uses the spCheckForVehicleModelMatch Database Object to provide the following matching logic:

  • Existing records that match a new record's Year, Model Name, and Manufacturer are flagged as absolute matches.
  • Existing records that match a new record's Model Name and Manufacturer (but not year) are flagged as potential duplicates.

This stored procedure receives the RecordID, Year, and ModelName from the CheckForDuplicate method (using the values from the current GE object) to check and returns a Match Type and if a match is found, a list of matching IDs. This stored procedure returns one of the following Match Values:

  • 0: No duplicates found
  • 1: Absolute Match Found, the record ID(s) of the absolute match will be placed in the arDuplicates array
  • 2: Possible Match(s) found, the record ID(s) of the potential match(s) will be placed in the arDuplicates array

The text of the spCheckForVehicleModelMatch stored procedure appears below but you can also find it in the Database Objects service if you installed the sample application.

CREATE PROC
spCheckForVehicleModelMatch 
                               (@SourceID INT,
                                @Year INT,
                                @Name NVARCHAR(255),
                                @ManufacturerID INT)
AS
SELECT MatchType, ID FROM 
(SELECT MatchType 
= CASE
                WHEN 
                                (Year = @Year AND
                                 Name = @Name AND
                                 ManufacturerID = @ManufacturerID AND
                                 ID <> @SourceID)
                THEN
                                1
                WHEN
                                (Name = @Name AND
                                 ManufacturerID = @ManufacturerID AND
                                 ID <> @SourceID)
                THEN
                                2
                END,

ID FROM APTIFY..vwVehicleModels) VehicleModelMatch
WHERE MatchType IS NOT NULL 

 

About the Baseline Persons and Companies Sample Duplicate Objects

The standard Aptify installation provides the compiled object and source code for two sample duplicate check objects: one for Persons and one for Companies. Note that these objects are provided as samples only since what may be considered a duplicate will vary from entity-to-entity and from organization-to-organization. The sample objects use the following logic to identify duplicates:

  • Sample Persons Duplicate Check Object (AptifyPersonDupeCheck.dll): When a user attempts to save a new Persons record, this sample object checks for existing Persons records that have the same First and Last Name. If any matches exist, Aptify identifies these records as potential duplicates.
  • Sample Companies Duplicate Check Object (AptifyCompanyDupeCheck.dll): When a user attempts to save a new Companies record, this sample object checks for existing Companies records that have the same exact Name. If any matches exist, Aptify identifies these records as potential duplicates.

By default, the Aptify installer adds these sample objects to the Aptify Object Repository, but the duplicate checking functionality is not enabled.

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.