Skip to content

EspoCRM – Open Source CRM Application

Notification reaction load parent, ref

Yuriie66521db1be6
diff --git a/application/Espo/Entities/Notification.php b/application/Espo/Entities/Notification.php
index 47a4828ac4..1a17675417 100644
--- a/application/Espo/Entities/Notification.php
+++ b/application/Espo/Entities/Notification.php
@@ -63,6 +63,10 @@ class Notification extends Entity
public const string FIELD_MESSAGE = 'message';
public const string FIELD_TYPE = 'type';
public const string FIELD_RELATED_PARENT = 'relatedParent';
+ /**
+ * @since 10.0.0
+ */
+ public const string FIELD_RELATED = 'related';
public const string FIELD_IS_FEATURED = 'isFeatured';
public const string GROUP_TYPE_RECORD = 'Record';
diff --git a/application/Espo/Tools/Notification/RecordService.php b/application/Espo/Tools/Notification/RecordService.php
index 91a3f3c7f3..801d6edda2 100644
--- a/application/Espo/Tools/Notification/RecordService.php
+++ b/application/Espo/Tools/Notification/RecordService.php
@@ -269,6 +269,10 @@ class RecordService
$this->loadNoteFields($note, $entity);
$entity->set('noteData', $note->getValueMap());
+
+ if ($entity->getType() === Notification::TYPE_USER_REACTION) {
+ $entity->loadParentNameField(Notification::FIELD_RELATED_PARENT);
+ }
}
/**
@@ -370,11 +374,7 @@ class RecordService
if ($parentId && $parentType) {
if ($notification->getType() !== Notification::TYPE_USER_REACTION) {
- $parent = $this->entityManager->getEntityById($parentType, $parentId);
-
- if ($parent) {
- $note->set('parentName', $parent->get(Field::NAME));
- }
+ $note->loadParentNameField(Field::PARENT);
}
} else if (!$note->isGlobal()) {
$targetType = $note->getTargetType();
@@ -396,11 +396,7 @@ class RecordService
$relatedType = $note->getRelatedType();
if ($relatedId && $relatedType && $notification->getType() !== Notification::TYPE_USER_REACTION) {
- $related = $this->entityManager->getEntityById($relatedType, $relatedId);
-
- if ($related) {
- $note->set('relatedName', $related->get(Field::NAME));
- }
+ $note->loadParentNameField(Notification::FIELD_RELATED);
}
if ($notification->getType() !== Notification::TYPE_USER_REACTION) {