Skip to content

EspoCRM – Open Source CRM Application

note about assignment populate names

Yuriia43e14a33f26
diff --git a/application/Espo/Tools/Stream/Service.php b/application/Espo/Tools/Stream/Service.php
index 58f96f1ae3..a20f245f62 100644
--- a/application/Espo/Tools/Stream/Service.php
+++ b/application/Espo/Tools/Stream/Service.php
@@ -1176,6 +1176,8 @@ class Service
/** @var array<string, ?string> $newNames */
$newNames = get_object_vars($entity->get(self::FIELD_ASSIGNED_USERS . 'Names') ?? (object) []);
+ $this->prepareUserNameMap($newIds, $newNames);
+
/** @var string[] $prevIds */
$prevIds = $entity->getFetched(self::FIELD_ASSIGNED_USERS . 'Ids') ?? [];
/** @var array<string, ?string> $prevNames */
@@ -1338,4 +1340,21 @@ class Service
return $statusData;
}
+
+ /**
+ * @param string[] $ids
+ * @param array<string, ?string> $names
+ */
+ private function prepareUserNameMap(array $ids, array &$names): void
+ {
+ foreach ($ids as $id) {
+ if (array_key_exists($id, $names) && $names[$id] !== null) {
+ continue;
+ }
+
+ $user = $this->entityManager->getRDBRepositoryByClass(User::class)->getById($id);
+
+ $names[$id] = $user?->getName() ?? null;
+ }
+ }
}