From 08b30d9f8e3ce5b804b87baba2aa6571d0664ce2 Mon Sep 17 00:00:00 2001
From: "b.ulrich" <b.ulrich@adito.de>
Date: Wed, 24 Mar 2021 07:48:45 +0100
Subject: [PATCH] =?UTF-8?q?[Projekt:=20xRM-Sales][TicketNr.:=201074369][Pr?=
 =?UTF-8?q?oductprice:=20Falsche=20Lademethode=20f=C3=BChrt=20zu=20Perform?=
 =?UTF-8?q?anceproblemen]?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../Productprice_entity/Productprice_entity.aod   |  1 +
 .../product_id/displayValueProcess.js             | 15 +++++++++++++++
 .../product_id.displayvalue/expression.js         |  5 +----
 3 files changed, 17 insertions(+), 4 deletions(-)
 create mode 100644 entity/Productprice_entity/entityfields/product_id/displayValueProcess.js

diff --git a/entity/Productprice_entity/Productprice_entity.aod b/entity/Productprice_entity/Productprice_entity.aod
index 3dbcf1f9873..db95abf550f 100644
--- a/entity/Productprice_entity/Productprice_entity.aod
+++ b/entity/Productprice_entity/Productprice_entity.aod
@@ -64,6 +64,7 @@
       <mandatory v="true" />
       <stateProcess>%aditoprj%/entity/Productprice_entity/entityfields/product_id/stateProcess.js</stateProcess>
       <valueProcess>%aditoprj%/entity/Productprice_entity/entityfields/product_id/valueProcess.js</valueProcess>
+      <displayValueProcess>%aditoprj%/entity/Productprice_entity/entityfields/product_id/displayValueProcess.js</displayValueProcess>
     </entityField>
     <entityField>
       <name>CONTACT_ID</name>
diff --git a/entity/Productprice_entity/entityfields/product_id/displayValueProcess.js b/entity/Productprice_entity/entityfields/product_id/displayValueProcess.js
new file mode 100644
index 00000000000..bee4e1ff594
--- /dev/null
+++ b/entity/Productprice_entity/entityfields/product_id/displayValueProcess.js
@@ -0,0 +1,15 @@
+import("system.result");
+import("system.neon");
+import("system.vars");
+import("Sql_lib");
+
+
+// TODO: This should only be a temporary solution, till it's possible to also group fields of pageable dbRecordContainers that have their displayValue set via displayValueExpression (#1077182)
+if((vars.exists("$param.ProductId_param") && vars.get("$param.ProductId_param") && vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
+    || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_VIEW)
+{
+    result.string(newSelect("PRODUCTNAME")
+                    .from("PRODUCT")
+                    .whereIfSet("PRODUCT.PRODUCTID", "$field.PRODUCT_ID")
+                    .cell());
+}
\ No newline at end of file
diff --git a/entity/Productprice_entity/recordcontainers/db/recordfieldmappings/product_id.displayvalue/expression.js b/entity/Productprice_entity/recordcontainers/db/recordfieldmappings/product_id.displayvalue/expression.js
index cbc5d9d359d..c7a17f50a06 100644
--- a/entity/Productprice_entity/recordcontainers/db/recordfieldmappings/product_id.displayvalue/expression.js
+++ b/entity/Productprice_entity/recordcontainers/db/recordfieldmappings/product_id.displayvalue/expression.js
@@ -1,4 +1 @@
-import("system.result");
-
-result.string("select PRODUCTNAME from PRODUCT \n\
-        where PRODUCT.PRODUCTID = PRODUCTPRICE.PRODUCT_ID");
\ No newline at end of file
+// TODO: Fill this instead of the displayValueProcess once it's possible to also group fields of pageable dbRecordContainers that have their displayValue set via displayValueExpression (#1077182)
\ No newline at end of file
-- 
GitLab