Regression v10.0.6: Foreign field with relateOnImport filtered out during CSV import

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • awehrlin
    Junior Member
    • Aug 2026
    • 1

    #1

    Regression v10.0.6: Foreign field with relateOnImport filtered out during CSV import

    Hello,

    We are currently using EspoCRM 10.0.6, after migrating from 9.3.5.

    We have a custom entity Company (CSociete) with a many-to-one / belongsTo relationship to a custom Address entity (CAdresses).

    On CSociete, we have a custom Foreign field:
    • field name: adresseIdentifiantExterne
    • type: foreign
    • link: adresse
    • foreign field: identifiantExterne
    • relateOnImport: true

    The target field CAdresses.identifiantExterne is a varchar field and contains unique external identifiers such as: FINESS:130807068

    This setup used to work correctly in EspoCRM 9.3.5: during CSV import, mapping a CSV column to adresseIdentifiantExterne automatically resolved the related Address and populated the adresse relation.

    After upgrading to 10.0.6, this no longer works.

    The import itself completes without a relation being created. If the adresse field is marked as required, the import fails with a validation error because adresseId remains null.

    We performed some debugging and found the following.

    The metadata is correct:
    "adresseIdentifiantExterne": {
    "readOnly": true,
    "type": "foreign",
    "link": "adresse",
    "field": "identifiantExterne",
    "relateOnImport": true,
    "isCustom": true
    }

    The relationship is also correctly defined as belongsTo:
    "adresse": {
    "type": "belongsTo",
    "foreign": "societes",
    "entity": "CAdresses",
    "isCustom": true
    }

    We confirmed through the ORM that:
    • adresseIdentifiantExterne is recognized as a foreign attribute;
    • its foreign field is correctly resolved as identifiantExterne;
    • its relation is correctly resolved as adresse;
    • adresseId exists as an attribute;
    • the related CAdresses record can be successfully found through the ORM with:
    $entityManager->getRDBRepository('CAdresses')->where(['identifiantExterne' => 'FINESS:130807068',])->findOne();

    The Address record is correctly returned.

    The important difference seems to occur during import processing.

    The CSV mapping contains both:
    • siret
    • adresseIdentifiantExterne

    However, after the import is created, the stored attributeList only contains: ["siret"]

    adresseIdentifiantExterne has been removed.

    We then checked the ACL forbidden attribute list for CSociete and found: "adresseIdentifiantExterne" is included in getScopeForbiddenAttributeList(..., ACTION_EDIT).

    This seems to cause the Foreign field to be removed from the import attribute list before processForeignFields() / relateOnImport gets a chance to resolve the related Address.

    So it looks like there may be a regression between 9.3.5 and 10.0.6 where Foreign fields with relateOnImport: true are filtered out by the edit ACL during import because they are read-only.

    Could you please confirm whether this is an expected behavior in 10.0.6, or whether this is a regression?

    If it is expected, is there now an additional metadata parameter required for Foreign fields used with relateOnImport?

    Thank you.
  • yuri
    EspoCRM product developer
    • Mar 2014
    • 10034

    #2
    Hi,

    Thank you for reporting.

    Fix: https://github.com/espocrm/espocrm/c...1fbc68692eff3f

    Comment

    Working...