Skip to content

EspoCRM – Open Source CRM Application

Formula create/update more restriction

Yuriid9413858c8c0
diff --git a/application/Espo/Core/Formula/Functions/RecordGroup/CreateType.php b/application/Espo/Core/Formula/Functions/RecordGroup/CreateType.php
index 5c900c4d18..70b7de49ba 100644
--- a/application/Espo/Core/Formula/Functions/RecordGroup/CreateType.php
+++ b/application/Espo/Core/Formula/Functions/RecordGroup/CreateType.php
@@ -36,6 +36,7 @@ use Espo\Core\Formula\Exceptions\TooFewArguments;
use Espo\Core\Formula\Func;
use Espo\Core\Formula\Utils\EntityUtil;
use Espo\ORM\EntityManager;
+use Espo\ORM\Name\Attribute;
use stdClass;
/**
@@ -64,7 +65,7 @@ class CreateType implements Func
$notAllowedAttributes = array_intersect(
array_keys($data),
- $this->entityUtil->getWriteRestrictedAttributeList($entityType),
+ $this->getWriteRestrictedAttributeList($entityType),
);
if ($notAllowedAttributes) {
@@ -113,4 +114,15 @@ class CreateType implements Func
return $data;
}
+
+ /**
+ * @return string[]
+ */
+ private function getWriteRestrictedAttributeList(string $entityType): array
+ {
+ return [
+ ...$this->entityUtil->getWriteRestrictedAttributeList($entityType),
+ Attribute::ID,
+ ];
+ }
}
diff --git a/application/Espo/Core/Formula/Functions/RecordGroup/UpdateType.php b/application/Espo/Core/Formula/Functions/RecordGroup/UpdateType.php
index 29ff172257..1bf8be2568 100644
--- a/application/Espo/Core/Formula/Functions/RecordGroup/UpdateType.php
+++ b/application/Espo/Core/Formula/Functions/RecordGroup/UpdateType.php
@@ -36,6 +36,7 @@ use Espo\Core\Formula\Exceptions\TooFewArguments;
use Espo\Core\Formula\Func;
use Espo\Core\Formula\Utils\EntityUtil;
use Espo\ORM\EntityManager;
+use Espo\ORM\Name\Attribute;
use stdClass;
/**
@@ -69,7 +70,7 @@ class UpdateType implements Func
$notAllowedAttributes = array_intersect(
array_keys($data),
- $this->entityUtil->getWriteRestrictedAttributeList($entityType),
+ $this->getWriteRestrictedAttributeList($entityType),
);
if ($notAllowedAttributes) {
@@ -123,4 +124,15 @@ class UpdateType implements Func
return $data;
}
+
+ /**
+ * @return string[]
+ */
+ private function getWriteRestrictedAttributeList(string $entityType): array
+ {
+ return [
+ ...$this->entityUtil->getWriteRestrictedAttributeList($entityType),
+ Attribute::ID,
+ ];
+ }
}