From 49125f36cada33fa2dcf7b978c3308e403f199e0 Mon Sep 17 00:00:00 2001
From: Sebastian Listl <s.listl@adito.de>
Date: Thu, 8 Oct 2020 08:55:44 +0200
Subject: [PATCH] #1065119 Employee email address not changeable

---
 entity/Employee_entity/Employee_entity.aod               | 1 +
 .../entityfields/email_address/stateProcess.js           | 9 +++++++++
 2 files changed, 10 insertions(+)
 create mode 100644 entity/Employee_entity/entityfields/email_address/stateProcess.js

diff --git a/entity/Employee_entity/Employee_entity.aod b/entity/Employee_entity/Employee_entity.aod
index 60ea8401f6..c3144f1349 100644
--- a/entity/Employee_entity/Employee_entity.aod
+++ b/entity/Employee_entity/Employee_entity.aod
@@ -64,6 +64,7 @@
       <mandatory v="true" />
       <dropDownProcess>%aditoprj%/entity/Employee_entity/entityfields/email_address/dropDownProcess.js</dropDownProcess>
       <textInputAllowed v="true" />
+      <stateProcess>%aditoprj%/entity/Employee_entity/entityfields/email_address/stateProcess.js</stateProcess>
       <onValidation>%aditoprj%/entity/Employee_entity/entityfields/email_address/onValidation.js</onValidation>
     </entityField>
     <entityField>
diff --git a/entity/Employee_entity/entityfields/email_address/stateProcess.js b/entity/Employee_entity/entityfields/email_address/stateProcess.js
new file mode 100644
index 0000000000..41639552ec
--- /dev/null
+++ b/entity/Employee_entity/entityfields/email_address/stateProcess.js
@@ -0,0 +1,9 @@
+import("system.result");
+import("system.neon");
+import("system.vars");
+
+//the email should not be changed afterwards, because it is also used as calendar id
+if (!vars.get("$field.EMAIL_ADDRESS") || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
+    result.string(neon.COMPONENTSTATE_EDITABLE);
+else
+    result.string(neon.COMPONENTSTATE_READONLY);
-- 
GitLab