From 95bbbb1daa9ea29e205b8a539f2316b04dcb9c98 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Thu, 10 Sep 2020 16:10:23 +0300 Subject: [PATCH] fix record service --- application/Espo/Services/Record.php | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/application/Espo/Services/Record.php b/application/Espo/Services/Record.php index b17f2d269e..80ab58db2e 100644 --- a/application/Espo/Services/Record.php +++ b/application/Espo/Services/Record.php @@ -449,13 +449,22 @@ class Record implements Crud, protected function loadLinkMultipleFields(Entity $entity) { - $fieldDefs = $this->getMetadata()->get('entityDefs.' . $entity->getEntityType() . '.fields', []); + $fieldDefs = $this->getMetadata()->get(['entityDefs', $entity->getEntityType(), 'fields']) ?? []; + foreach ($fieldDefs as $field => $defs) { - if (isset($defs['type']) && in_array($defs['type'], ['linkMultiple', 'attachmentMultiple']) && empty($defs['noLoad'])) { + if ( + isset($defs['type']) && + in_array($defs['type'], ['linkMultiple', 'attachmentMultiple']) && + empty($defs['noLoad']) && + empty($defs['notStorable']) && + $entity->hasRelation($field) + ) { $columns = null; + if (!empty($defs['columns'])) { $columns = $defs['columns']; } + $entity->loadLinkMultipleField($field, $columns); } } @@ -466,8 +475,15 @@ class Record implements Crud, foreach ($selectAttributeList as $attribute) { if ($entity->getAttributeParam($attribute, 'isLinkMultipleIdList')) { $field = $entity->getAttributeParam($attribute, 'relation'); - if (!$field) continue; - if ($entity->has($attribute)) continue; + + if (!$field) { + continue; + } + + if ($entity->has($attribute)) { + continue; + } + $entity->loadLinkMultipleField($field); } }