Specifying Custom Indexes for Import Duplicate Checking
When importing records to Sugar via the Import Wizard, users can select which of the mapped fields they would like to use to perform a duplicate check and thereby avoid creating duplicate records. This article explains how to enable an additional field or set of fields for selection in this step.
The import wizard's duplicate check operates based on indices defined for that module. You can create a non-database index to check for a field. It is important that it is non-database as single column indices on your database can hamper overall performance. The following is an example to add the home phone field to the Contact module's duplicate check.
First, create the following file from the root directory of your Sugar installation on the web server:
When creating the file, keep in mind the following requirements:
- The name of the file is not important, as long as it ends with a .php extension.
- The rest of the directory path is case sensitive so be sure to create the directories as shown.
- If you are creating the import index for a module other than Contacts, then substitute the corresponding directory name with that module.
- Ensure that the entire directory path and file have the correct ownership and sufficient permissions for the web server to access the file.
The contents of the file should look similar to the following code:
<?php $dictionary['Contact']['indices'] = array( 'name' => 'idx_home_phone_cstm', 'type' => 'index', 'fields' => array( 0 => 'phone_home', ), 'source' => 'non-db', );
Please note that the module name in line 2 of the code is singular (i.e. Contact, not Contacts). If you are unsure of what to enter for the module name, you can verify the name by opening the
./cache/modules/<module_name>/<module_name>vardefs.php file. The second line of that file will have text like the following:
$GLOBALS["dictionary"]["Contact"] = array (
The parameter following "dictionary" is the same parameter you should use in the file defining the custom index. To verify duplicates against a combination of fields (i.e. duplicates will only be flagged if the values of multiple fields match those of an existing record), then simply add the desired fields to the 'fields' array in the code example.
Finally, navigate to Admin > Repair > Quick Repair and Rebuild to enable the custom index for duplicate verification when importing records in the module.
Last modified: 2022-02-03 20:25:09