From 0833d66ada41223633af406fec3bce6b0022db73 Mon Sep 17 00:00:00 2001
From: Johannes Hoermann <j.hoermann@adito.de>
Date: Mon, 26 Aug 2019 16:54:10 +0200
Subject: [PATCH] fix display value appointment link

---
 .../AppointmentLink_entity/AppointmentLink_entity.aod |  4 ----
 .../entityfields/objectid/displayValueProcess.js      | 11 ++++++++---
 .../objectid.displayvalue/expression.js               |  4 ----
 3 files changed, 8 insertions(+), 11 deletions(-)
 delete mode 100644 entity/AppointmentLink_entity/recordcontainers/db/recordfieldmappings/objectid.displayvalue/expression.js

diff --git a/entity/AppointmentLink_entity/AppointmentLink_entity.aod b/entity/AppointmentLink_entity/AppointmentLink_entity.aod
index 092996034c..15831ec86e 100644
--- a/entity/AppointmentLink_entity/AppointmentLink_entity.aod
+++ b/entity/AppointmentLink_entity/AppointmentLink_entity.aod
@@ -135,10 +135,6 @@
           <name>OBJECTTYPE.value</name>
           <recordfield>AB_APPOINTMENTLINK.OBJECT_TYPE</recordfield>
         </dbRecordFieldMapping>
-        <dbRecordFieldMapping>
-          <name>OBJECTID.displayValue</name>
-          <expression>%aditoprj%/entity/AppointmentLink_entity/recordcontainers/db/recordfieldmappings/objectid.displayvalue/expression.js</expression>
-        </dbRecordFieldMapping>
         <dbRecordFieldMapping>
           <name>AB_APPOINTMENTLINKID.value</name>
           <recordfield>AB_APPOINTMENTLINK.AB_APPOINTMENTLINK_ID</recordfield>
diff --git a/entity/AppointmentLink_entity/entityfields/objectid/displayValueProcess.js b/entity/AppointmentLink_entity/entityfields/objectid/displayValueProcess.js
index b603d5545b..e95adef18a 100644
--- a/entity/AppointmentLink_entity/entityfields/objectid/displayValueProcess.js
+++ b/entity/AppointmentLink_entity/entityfields/objectid/displayValueProcess.js
@@ -1,6 +1,11 @@
-import("system.db");
+import("system.neon");
 import("system.vars");
+import("system.db");
 import("system.result");
-import("Context_lib")
+import("Context_lib");
 
-result.string(db.cell(ContextUtils.getNameSql(vars.get("$field.OBJECTTYPE"), vars.get("$field.OBJECTID"))));
\ No newline at end of file
+if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && !vars.get("$field.OBJECTID")) {
+    result.string("");
+} else if (vars.exists("$field.OBJECTTYPE") && vars.get("$field.OBJECTTYPE")) {
+    result.string(db.cell(ContextUtils.getNameSql(vars.get("$field.OBJECTTYPE"), vars.get("$field.OBJECTID"))));
+}
\ No newline at end of file
diff --git a/entity/AppointmentLink_entity/recordcontainers/db/recordfieldmappings/objectid.displayvalue/expression.js b/entity/AppointmentLink_entity/recordcontainers/db/recordfieldmappings/objectid.displayvalue/expression.js
deleted file mode 100644
index 33554680cc..0000000000
--- a/entity/AppointmentLink_entity/recordcontainers/db/recordfieldmappings/objectid.displayvalue/expression.js
+++ /dev/null
@@ -1,4 +0,0 @@
-import("system.result");
-import("Context_lib");
-
-result.string(ContextUtils.getNameSubselectSql("OBJECT_TYPE", "OBJECT_ROWID"))
\ No newline at end of file
-- 
GitLab