From bccf6f3a0e3f122957005ac6fff0bd1148902d41 Mon Sep 17 00:00:00 2001
From: Johannes Goderbauer <j.goderbauer@adito.de>
Date: Fri, 20 Mar 2020 12:49:13 +0000
Subject: [PATCH] Merge branch '1053354_FixContactIdInsteadOfEmail' into
 '2020.0'
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

[Projekt: Entwicklung - Neon][TicketNr.: 1053354][Auswählen von Empfänger beim...

See merge request xrm/basic!157

(cherry picked from commit c25a85e1866fcac0ed782c75ab69e71418e9c5a6)

cac194cc [Projekt: Entwicklung - Neon][TicketNr.: 1053354][Auswählen von Empfänger beim...
---
 entity/Email_entity/Email_entity.aod                        | 1 +
 entity/Email_entity/entityfields/recipient/onValueChange.js | 0
 entity/Email_entity/entityfields/recipient/valueProcess.js  | 6 +++++-
 3 files changed, 6 insertions(+), 1 deletion(-)
 create mode 100644 entity/Email_entity/entityfields/recipient/onValueChange.js

diff --git a/entity/Email_entity/Email_entity.aod b/entity/Email_entity/Email_entity.aod
index 54ab0155b80..f27af73fbb8 100644
--- a/entity/Email_entity/Email_entity.aod
+++ b/entity/Email_entity/Email_entity.aod
@@ -43,6 +43,7 @@
       <textInputAllowed v="true" />
       <valueProcess>%aditoprj%/entity/Email_entity/entityfields/recipient/valueProcess.js</valueProcess>
       <displayValueProcess>%aditoprj%/entity/Email_entity/entityfields/recipient/displayValueProcess.js</displayValueProcess>
+      <onValueChange>%aditoprj%/entity/Email_entity/entityfields/recipient/onValueChange.js</onValueChange>
     </entityField>
     <entityConsumer>
       <name>EmailAddresses</name>
diff --git a/entity/Email_entity/entityfields/recipient/onValueChange.js b/entity/Email_entity/entityfields/recipient/onValueChange.js
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/entity/Email_entity/entityfields/recipient/valueProcess.js b/entity/Email_entity/entityfields/recipient/valueProcess.js
index e83561d0e54..3ad60d78a7a 100644
--- a/entity/Email_entity/entityfields/recipient/valueProcess.js
+++ b/entity/Email_entity/entityfields/recipient/valueProcess.js
@@ -9,4 +9,8 @@ if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$this.v
         result.string(vars.get("$param.Recipient_param"));
     else if (vars.exists("$param.ContactId_param") && vars.get("$param.ContactId_param"))
         result.string(CommUtil.getStandardMail(vars.get("$param.ContactId_param")));
-}
\ No newline at end of file
+}
+else if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && !vars.get("$field.RECIPIENT").includes("@"))
+    result.string(newSelect("ADDR")
+                        .from("COMMUNICATION")
+                        .where("COMMUNICATION.COMMUNICATIONID", vars.get("$this.value")).cell());
\ No newline at end of file
-- 
GitLab