diff --git a/core/oql/expression.class.inc.php b/core/oql/expression.class.inc.php index 576a6090d..bb490313f 100644 --- a/core/oql/expression.class.inc.php +++ b/core/oql/expression.class.inc.php @@ -746,10 +746,30 @@ class ScalarExpression extends UnaryExpression { switch (true) { + case ($oAttDef instanceof AttributeExternalField): + try + { + if ($this->GetValue() == 0) + { + $aValue['label'] = Dict::S('UI:UndefinedObject'); + } + else + { + /** @var AttributeExternalKey $oAttDef */ + $sTarget = $oAttDef->GetFinalAttDef()->GetTargetClass(); + $oObj = MetaModel::GetObject($sTarget, $this->GetValue()); + + $aValue['label'] = $oObj->Get("friendlyname"); + } + } + catch (Exception $e) + { + IssueLog::Error($e->getMessage()); + } + break; case $oAttDef->IsExternalKey(): try { - if ($this->GetValue() == 0) { $aValue['label'] = Dict::S('UI:UndefinedObject'); diff --git a/sources/application/search/searchform.class.inc.php b/sources/application/search/searchform.class.inc.php index adca5e815..49932e35c 100644 --- a/sources/application/search/searchform.class.inc.php +++ b/sources/application/search/searchform.class.inc.php @@ -429,10 +429,12 @@ class SearchForm } if ($oAttrDef instanceof AttributeExternalField) { - // Let's propose every existing value - $oValSetDef = new ValueSetObjects('SELECT '.$sTargetClass); - $aAllowedValues = $oValSetDef->GetValues(array()); - return array('values' => $aAllowedValues, 'count' => count($aAllowedValues)); + $aAllowedValues = array(); + while ($oObject = $oSet->Fetch()) + { + $aAllowedValues[$oObject->GetKey()] = $oObject->GetName(); + } + return array('values' => $aAllowedValues, 'count' => $iCount); } } else