Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-7619

Saved mapping fields for import don't load properly using two different dedupe rules if fields are used for contact matching in just one of the rules

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 3.3.5
    • Fix Version/s: Unscheduled
    • Component/s: Core CiviCRM
    • Labels:
      None

      Description

      I have two dedupe rules, used one after another for different contact import operations using the same CSV file (One to bring in totally new contacts, one to intentionally make duplicates in case of name/address changes).

      In one of the rules, first_name is not used as one of the contact matching fileds, but in the other it is. When I use the first rule and load the mapping, all is well, but when I switch to the second rule and load the mapping, first_name isn't mapped to the correct field, and has to be chosen manually.

      This is because the civicrm_mapping_fields table stores 'First Name (match to contact)' the in the name field and then uses this to find the default from the mapper on line 576 of /CRM/Form/Import/MapField.php:

      $mappingHeader = array_keys($this->_mapperFields, $mappingName[$i]);

      Where $this->_mapperFields has an array item like this:

      [first_name] => 'First Name'

      I've put in a rough and ready fix like this:

      $mappingHeader = array_keys($this->_mapperFields, $mappingName[$i]);

      if (!$mappingHeader) {
      // add or remove the '(match to contacts)' bit and try again
      if (strpos($mappingName[$i], '(match to contact)') !== false)

      { $nameToFind = substr($mappingName[$i], 0, -19); }

      else

      { $nameToFind = $mappingName[$i].' (match to contact)'; }

      $mappingHeader = array_keys($this->_mapperFields, $nameToFind);
      }

      But I imagine it would be best to keep the '(match to contact)' bit out of the mapper_fields table entirely.

        Attachments

          Activity

            People

            • Assignee:
              lobo Donald A. Lobo
              Reporter:
              mattgibson Matt Gibson
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: