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

Empty data on custom data date/boolean import leads to silent drop of entire record, with solution

    Details

      Description

      When importing contacts, if a boolean or date custom field is included, and that field is empty, the import of the entire record is silently skipped without giving any error message or indication of a problem.

      Looking at /CRM/Import/Parser/Contact.php there are two causes of this problem:

      1. There is a validation step and an import step. Recent changes in the import step have left it out of sync with the validation step. So empty date/boolean custom fields pass the validation step but then cause the import step to choke.

      2. Errors on the import step are just ignored and not displayed or logged anywhere. This makes it difficult to troubleshoot errors that happen.

      Here is the solution to the first problem:

      In /CRM/Import/Parser/Contact.php around line 1164, make this addition:

      /* validate the data against the CF type */

      //For date & boolean custom fields, empty values are not allowed
      if ($value=="") {
      if (($customFields[$customFieldID]['data_type']) == 'Date' OR ($customFields[$customFieldID]['data_type'] == 'Boolean'))

      { self::addToErrorMsg($customFields[$customFieldID]['label'] . ": Boolean & Date Custom Fields may not be empty", $errorMessage); }


      } else
      /* end date & boolean custom fields addition */

      if ($value) {
      if ($customFields[$customFieldID]['data_type'] == 'Date') {
      if (CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key))

      { $value = $params[$key]; }

      else {

        Attachments

          Activity

            People

            • Assignee:
              lobo Donald A. Lobo
              Reporter:
              bhugh Brent Hugh
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: