diff --git a/application/Espo/Repositories/PhoneNumber.php b/application/Espo/Repositories/PhoneNumber.php index 1a879f2a7b..d57dccdbb3 100644 --- a/application/Espo/Repositories/PhoneNumber.php +++ b/application/Espo/Repositories/PhoneNumber.php @@ -228,9 +228,14 @@ class PhoneNumber extends \Espo\Core\ORM\Repositories\RDB foreach ($phoneNumberData as $row) { $key = trim($row->phoneNumber); if (empty($key)) continue; + if (isset($row->type)) { + $type = $row->type; + } else { + $type = $this->getMetadata()->get(['entityDefs', $entity->getEntityType(), 'fields', 'phoneNumber', 'defaultType']); + } $hash->$key = [ 'primary' => $row->primary ? true : false, - 'type' => $row->type, + 'type' => $type, 'optOut' => !empty($row->optOut) ? true : false, 'invalid' => !empty($row->invalid) ? true : false, ]; diff --git a/application/Espo/Services/Import.php b/application/Espo/Services/Import.php index 9b76675617..7526eb8f3f 100644 --- a/application/Espo/Services/Import.php +++ b/application/Espo/Services/Import.php @@ -599,6 +599,18 @@ class Import extends \Espo\Services\Record continue; } + if ($attribute === 'phoneNumber' && $type === 'phone') { + $phoneNumberData = $entity->get('phoneNumberData'); + $phoneNumberData = $phoneNumberData ?? []; + $o = (object) [ + 'phoneNumber' => $value, + 'primary' => true, + ]; + $phoneNumberData[] = $o; + $entity->set('phoneNumberData', $phoneNumberData); + continue; + } + if ($type == 'personName') { $firstNameAttribute = 'first' . ucfirst($attribute); $lastNameAttribute = 'last' . ucfirst($attribute); @@ -628,12 +640,12 @@ class Import extends \Espo\Services\Record } $type = str_replace('phoneNumber', '', $attribute); $type = str_replace('_', ' ', $type); - $o = (object) []; - $o->phoneNumber = $value; - $o->type = $type; - $o->primary = $isPrimary; + $o = (object) [ + 'phoneNumber' => $value, + 'type' => $type, + 'primary' => $isPrimary, + ]; $phoneNumberData[] = $o; - $entity->set('phoneNumberData', $phoneNumberData); } diff --git a/client/src/views/import/step2.js b/client/src/views/import/step2.js index 01ee1088ef..83d74a5880 100644 --- a/client/src/views/import/step2.js +++ b/client/src/views/import/step2.js @@ -200,7 +200,8 @@ Espo.define('views/import/step2', 'view', function (Dep) { } if (d.type == 'phone') { - (this.getMetadata().get('entityDefs.' + this.scope + '.fields.' + field + '.typeList' ) || []).map(function (item) { + attributeList.push(field); + (this.getMetadata().get('entityDefs.' + this.scope + '.fields.' + field + '.typeList') || []).map(function (item) { return item.replace(/\s/g, '_'); }, this).forEach(function (item) { attributeList.push(field + Espo.Utils.upperCaseFirst(item));