From 59c324856590cbc40c40e3fb5524c18431358b9d Mon Sep 17 00:00:00 2001
From: Johannes Hoermann <j.hoermann@adito.de>
Date: Tue, 23 Jul 2019 16:19:30 +0200
Subject: [PATCH] support ticket / task fixes

---
 .../task_requestor_contact_id/displayValueProcess.js         | 5 ++---
 .../entityfields/task_requestor_contact_id/valueProcess.js   | 2 +-
 .../task_editor_contact_id.displayvalue/expression.js        | 5 +++++
 .../task_requestor_contact_id.displayvalue/expression.js     | 5 +++++
 .../editor_contact_id.displayvalue/expression.js             | 1 -
 5 files changed, 13 insertions(+), 5 deletions(-)
 create mode 100644 entity/SupportTicket_entity/recordcontainers/db/recordfieldmappings/task_editor_contact_id.displayvalue/expression.js
 create mode 100644 entity/SupportTicket_entity/recordcontainers/db/recordfieldmappings/task_requestor_contact_id.displayvalue/expression.js

diff --git a/entity/SupportTicket_entity/entityfields/task_requestor_contact_id/displayValueProcess.js b/entity/SupportTicket_entity/entityfields/task_requestor_contact_id/displayValueProcess.js
index 0dde82e772..35ee9d5af2 100644
--- a/entity/SupportTicket_entity/entityfields/task_requestor_contact_id/displayValueProcess.js
+++ b/entity/SupportTicket_entity/entityfields/task_requestor_contact_id/displayValueProcess.js
@@ -2,7 +2,6 @@ import("system.result");
 import("system.vars");
 import("Contact_lib");
 
-var id = vars.get("$this.value");
-//show the simpel title since this will be later an employee-entry and therefore no organisation is needed
-var title = ContactUtils.getTitleByContactId(id);
+//show the simpel title since this is an employee-entry and therefore no organisation is needed
+var title = ContactUtils.getTitleByContactId(vars.get("$field.TASK_REQUESTOR_CONTACT_ID"));
 result.string(title);
\ No newline at end of file
diff --git a/entity/SupportTicket_entity/entityfields/task_requestor_contact_id/valueProcess.js b/entity/SupportTicket_entity/entityfields/task_requestor_contact_id/valueProcess.js
index 1e62e7551c..4711a17716 100644
--- a/entity/SupportTicket_entity/entityfields/task_requestor_contact_id/valueProcess.js
+++ b/entity/SupportTicket_entity/entityfields/task_requestor_contact_id/valueProcess.js
@@ -3,5 +3,5 @@ import("system.neon");
 import("system.vars");
 import("Employee_lib");
 
-if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
+if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$this.value") == null)
     result.string(EmployeeUtils.getCurrentContactId());
\ No newline at end of file
diff --git a/entity/SupportTicket_entity/recordcontainers/db/recordfieldmappings/task_editor_contact_id.displayvalue/expression.js b/entity/SupportTicket_entity/recordcontainers/db/recordfieldmappings/task_editor_contact_id.displayvalue/expression.js
new file mode 100644
index 0000000000..8e7ea35c7f
--- /dev/null
+++ b/entity/SupportTicket_entity/recordcontainers/db/recordfieldmappings/task_editor_contact_id.displayvalue/expression.js
@@ -0,0 +1,5 @@
+import("system.result");
+import("Person_lib");
+
+var subSql = PersUtils.getResolvingDisplaySubSql("TASK.EDITOR_CONTACT_ID");
+result.string(subSql);
\ No newline at end of file
diff --git a/entity/SupportTicket_entity/recordcontainers/db/recordfieldmappings/task_requestor_contact_id.displayvalue/expression.js b/entity/SupportTicket_entity/recordcontainers/db/recordfieldmappings/task_requestor_contact_id.displayvalue/expression.js
new file mode 100644
index 0000000000..10b4b9967c
--- /dev/null
+++ b/entity/SupportTicket_entity/recordcontainers/db/recordfieldmappings/task_requestor_contact_id.displayvalue/expression.js
@@ -0,0 +1,5 @@
+import("system.result");
+import("Person_lib");
+
+var subSql = PersUtils.getResolvingDisplaySubSql("TASK.REQUESTOR_CONTACT_ID");
+result.string(subSql);
\ No newline at end of file
diff --git a/entity/Task_entity/recordcontainers/db/recordfieldmappings/editor_contact_id.displayvalue/expression.js b/entity/Task_entity/recordcontainers/db/recordfieldmappings/editor_contact_id.displayvalue/expression.js
index e5961584dd..8e7ea35c7f 100644
--- a/entity/Task_entity/recordcontainers/db/recordfieldmappings/editor_contact_id.displayvalue/expression.js
+++ b/entity/Task_entity/recordcontainers/db/recordfieldmappings/editor_contact_id.displayvalue/expression.js
@@ -1,6 +1,5 @@
 import("system.result");
 import("Person_lib");
 
-//TODO: try to find a better solution for this -> #TITLE-mechanic when available
 var subSql = PersUtils.getResolvingDisplaySubSql("TASK.EDITOR_CONTACT_ID");
 result.string(subSql);
\ No newline at end of file
-- 
GitLab