diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 3e47fdc3bd..9bb4756913 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -661,7 +661,14 @@ abstract class cmdbAbstractObject extends CMDBObject { $sExtKeyLabel = MetaModel::GetLabel($sClassName, $oAttDef->GetKeyAttCode()); $sRemoteAttLabel = MetaModel::GetLabel($oAttDef->GetTargetClass(), $oAttDef->GetExtAttCode()); - $aHeader[] = $sExtKeyLabel.'->'.$sRemoteAttLabel; + $oTargetAttDef = MetaModel::GetAttributeDef($oAttDef->GetTargetClass(), $oAttDef->GetExtAttCode()); + $sSuffix = ''; + if ($oTargetAttDef->IsExternalKey()) + { + $sSuffix = '->id'; + } + + $aHeader[] = $sExtKeyLabel.'->'.$sRemoteAttLabel.$sSuffix; } else { diff --git a/pages/ajax.csvimport.php b/pages/ajax.csvimport.php index b24caa3ca1..6b402014d8 100644 --- a/pages/ajax.csvimport.php +++ b/pages/ajax.csvimport.php @@ -70,10 +70,16 @@ function GetMappingsForExtKey($sAttCode, AttributeDefinition $oExtKeyAttDef, $bA { if (MetaModel::IsReconcKey($sTargetClass, $sTargetAttCode)) { - if ($bAdvanced || !$oTargetAttDef->IsExternalKey()) + $bExtKey = $oTargetAttDef->IsExternalKey(); + $sSuffix = ''; + if ($bExtKey) + { + $sSuffix = '->id'; + } + if ($bAdvanced || !$bExtKey) { // When not in advanced mode do not allow to use reconciliation keys (on external keys) if they are themselves external keys ! - $aResult[$sAttCode.'->'.$sTargetAttCode] = $oExtKeyAttDef->GetLabel().'->'.$oTargetAttDef->GetLabel(); + $aResult[$sAttCode.'->'.$sTargetAttCode] = $oExtKeyAttDef->GetLabel().'->'.$oTargetAttDef->GetLabel().$sSuffix; } } } @@ -124,12 +130,18 @@ function GetMappingForField($sClassName, $sFieldName, $iFieldIndex, $bAdvancedMo { if (MetaModel::IsReconcKey($sTargetClass, $sTargetAttCode)) { - if ($bAdvancedMode || (!$oTargetAttDef->IsExternalKey())) + $bExtKey = $oTargetAttDef->IsExternalKey(); + $sSuffix = ''; + if ($bExtKey) + { + $sSuffix = '->id'; + } + if ($bAdvancedMode || !$bExtKey) { // When not in advanced mode do not allow to use reconciliation keys (on external keys) if they are themselves external keys ! - $aChoices[$sAttCode.'->'.$sTargetAttCode] = $oAttDef->GetLabel().'->'.$oTargetAttDef->GetLabel(); - if ((strcasecmp($sFieldName, $aChoices[$sAttCode.'->'.$sTargetAttCode]) == 0) || (strcasecmp($sFieldName, ($sAttCode.'->'.$sTargetAttCode)) == 0) ) + $aChoices[$sAttCode.'->'.$sTargetAttCode] = $oAttDef->GetLabel().'->'.$oTargetAttDef->GetLabel().$sSuffix; + if ((strcasecmp($sFieldName, $aChoices[$sAttCode.'->'.$sTargetAttCode]) == 0) || (strcasecmp($sFieldName, ($sAttCode.'->'.$sTargetAttCode.$sSuffix)) == 0) ) { $sFieldCode = $sAttCode.'->'.$sTargetAttCode; }