diff --git a/application/Espo/Core/Formula/Functions/EntityGroup/GetLinkColumnType.php b/application/Espo/Core/Formula/Functions/EntityGroup/GetLinkColumnType.php index 5cd278ceba..daf652ceca 100644 --- a/application/Espo/Core/Formula/Functions/EntityGroup/GetLinkColumnType.php +++ b/application/Espo/Core/Formula/Functions/EntityGroup/GetLinkColumnType.php @@ -65,6 +65,8 @@ class GetLinkColumnType extends \Espo\Core\Formula\Functions\Base implements $entityType = $this->getEntity()->getEntityType(); $repository = $this->entityManager->getRDBRepository($entityType); - return $repository->getRelationColumn($this->getEntity(), $link, $id, $column); + return $repository + ->getRelation($this->getEntity(), $link) + ->getColumnById($id, $column); } } diff --git a/application/Espo/ORM/Repository/RDBRelation.php b/application/Espo/ORM/Repository/RDBRelation.php index 9b60d1e8db..76c5bf9911 100644 --- a/application/Espo/ORM/Repository/RDBRelation.php +++ b/application/Espo/ORM/Repository/RDBRelation.php @@ -487,7 +487,7 @@ class RDBRelation /** * Update relationship columns by ID. For many-to-many relationships. * - * @param array $columnData Role values. + * @param array $columnData Role values. */ public function updateColumnsById(string $id, array $columnData): void { @@ -606,6 +606,18 @@ class RDBRelation return $this->getMapper()->getRelationColumn($this->entity, $this->relationName, $id, $column); } + /** + * Get a relationship column value by a foreign record ID. For many-to-many relationships. + */ + public function getColumnById(string $id, string $column): string|int|float|bool|null + { + if ($this->relationType !== Entity::MANY_MANY) { + throw new RuntimeException("Can't get a column of not many-to-many relation."); + } + + return $this->getMapper()->getRelationColumn($this->entity, $this->relationName, $id, $column); + } + /** * @param array|null $columnData Role values. * @param array $options