From 68e4927a31517b6580dccbe4f4a8e28252de50cb Mon Sep 17 00:00:00 2001
From: Johannes Hoermann <j.hoermann@adito.de>
Date: Wed, 24 Jul 2019 11:12:46 +0200
Subject: [PATCH] refactor value processes: use this.value

---
 .../moduletrees/children/id/valueProcess.js   |  4 ---
 .../entityfields/summary/valueProcess.js      |  4 +--
 .../entityfields/uid/valueProcess.js          |  4 +--
 .../ab_attribute_id/valueProcess.js           | 16 ++++++------
 .../full_attribute_name/valueProcess.js       | 20 +++++++-------
 .../entityfields/address_id/valueProcess.js   |  2 +-
 .../entityfields/condition/valueProcess.js    |  4 +--
 .../duplicatescan_id/valueProcess.js          |  2 +-
 .../entityfields/header/valueProcess.js       |  5 ++--
 .../entityfields/role/valueProcess.js         |  2 +-
 .../entityfields/address_id/valueProcess.js   | 26 +++++++++----------
 .../entityfields/quantity/valueProcess.js     |  2 +-
 12 files changed, 44 insertions(+), 47 deletions(-)

diff --git a/entity/Activity_entity/entityfields/moduletrees/children/id/valueProcess.js b/entity/Activity_entity/entityfields/moduletrees/children/id/valueProcess.js
index 06fe7d36324..e69de29bb2d 100644
--- a/entity/Activity_entity/entityfields/moduletrees/children/id/valueProcess.js
+++ b/entity/Activity_entity/entityfields/moduletrees/children/id/valueProcess.js
@@ -1,4 +0,0 @@
-import("system.result");
-import("system.vars");
-
-result.string(vars.get("$field.ACTIVITYID"));
\ No newline at end of file
diff --git a/entity/Appointment_entity/entityfields/summary/valueProcess.js b/entity/Appointment_entity/entityfields/summary/valueProcess.js
index 11b4a7d531c..ce113bfd419 100644
--- a/entity/Appointment_entity/entityfields/summary/valueProcess.js
+++ b/entity/Appointment_entity/entityfields/summary/valueProcess.js
@@ -6,7 +6,7 @@ import("system.result");
 /**
  * Following if() is only for passing param-parts from "new Appointment"-Dialog to AppointmentEditViewTemplate
  */
-if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.exists("$param.Entry_param") && !vars.get("$field.SUMMARY"))
+if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.exists("$param.Entry_param") && vars.get("$this.value") == null)
 {
     var event = JSON.parse(vars.getString("$param.Entry_param"));
 
@@ -14,4 +14,4 @@ if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.exists("$para
         result.string(event[calendars.SUMMARY]);
 }
 else
-    result.string(vars.get("$field.SUMMARY"));
\ No newline at end of file
+    result.string(vars.get("$this.value"));
\ No newline at end of file
diff --git a/entity/Appointment_entity/entityfields/uid/valueProcess.js b/entity/Appointment_entity/entityfields/uid/valueProcess.js
index 85c485a5e49..5b429ea087f 100644
--- a/entity/Appointment_entity/entityfields/uid/valueProcess.js
+++ b/entity/Appointment_entity/entityfields/uid/valueProcess.js
@@ -2,7 +2,7 @@ import("system.vars");
 import("system.result");
 import("system.util");
 
-if(!(vars.get("$field.UID")))
+if(!(vars.get("$this.value")))
     result.string(util.getNewUUID());
 else
-    result.string(vars.get("$field.UID"));
\ No newline at end of file
+    result.string(vars.get("$this.value"));
\ No newline at end of file
diff --git a/entity/AttributeUsage_entity/entityfields/ab_attribute_id/valueProcess.js b/entity/AttributeUsage_entity/entityfields/ab_attribute_id/valueProcess.js
index 9efed36fc26..37bcaa77b0d 100644
--- a/entity/AttributeUsage_entity/entityfields/ab_attribute_id/valueProcess.js
+++ b/entity/AttributeUsage_entity/entityfields/ab_attribute_id/valueProcess.js
@@ -1,8 +1,8 @@
-import("system.vars");
-import("system.result");
-import("system.neon");
-
-if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.exists("$param.AttributeId_param") && vars.get("$param.AttributeId_param") != null)
-    result.string(vars.get("$param.AttributeId_param"));
-else if (vars.get("$field.AB_ATTRIBUTE_ID"))
-    result.string(vars.get("$field.AB_ATTRIBUTE_ID"));
\ No newline at end of file
+import("system.vars");
+import("system.result");
+import("system.neon");
+
+if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.exists("$param.AttributeId_param") && vars.get("$param.AttributeId_param") != null)
+    result.string(vars.get("$param.AttributeId_param"));
+else if (vars.get("$this.value"))
+    result.string(vars.get("$this.value"));
\ No newline at end of file
diff --git a/entity/Attribute_entity/entityfields/full_attribute_name/valueProcess.js b/entity/Attribute_entity/entityfields/full_attribute_name/valueProcess.js
index ef43e6922be..8778b5d4099 100644
--- a/entity/Attribute_entity/entityfields/full_attribute_name/valueProcess.js
+++ b/entity/Attribute_entity/entityfields/full_attribute_name/valueProcess.js
@@ -1,11 +1,11 @@
-import("system.vars");
-import("system.result");
-import("Attribute_lib");
-
-var name = vars.get("$field.ATTRIBUTE_NAME");
-if (!(vars.exists("$param.DisplaySimpleName_param") && vars.get("$param.DisplaySimpleName_param")))
-{
-    var parentName = AttributeUtil.getFullAttributeName(vars.get("$field.ATTRIBUTE_PARENT_ID"));
-    name = (parentName ? parentName + " / " : "") + name;
-}
+import("system.vars");
+import("system.result");
+import("Attribute_lib");
+
+var name = vars.get("$this.value");
+if (!(vars.exists("$param.DisplaySimpleName_param") && vars.get("$param.DisplaySimpleName_param")))
+{
+    var parentName = AttributeUtil.getFullAttributeName(vars.get("$field.ATTRIBUTE_PARENT_ID"));
+    name = (parentName ? parentName + " / " : "") + name;
+}
 result.string(name);
\ No newline at end of file
diff --git a/entity/Contact_entity/entityfields/address_id/valueProcess.js b/entity/Contact_entity/entityfields/address_id/valueProcess.js
index 0ddd690f6cc..75bc8b76629 100644
--- a/entity/Contact_entity/entityfields/address_id/valueProcess.js
+++ b/entity/Contact_entity/entityfields/address_id/valueProcess.js
@@ -3,7 +3,7 @@ import("system.vars");
 import("StandardObject_lib");
 
 //  Check if the standard address is already set.
-if (vars.get("$field.ADDRESS_ID") === null || vars.get("$field.ADDRESS_ID") === "" || vars.get("$field.ADDRESS_ID") == 0) {
+if (vars.get("$this.value") === null || vars.get("$this.value") === "" || vars.get("$this.value") == 0) {
     var possibleStandardAddressID = new StandardObject("Address", null, "Person", vars.get("$field.CONTACTID"))
         .onPersonValueChange(vars.get("$field.ORGANISATION_ID"));
 
diff --git a/entity/DuplicateScanConditionConfig_entity/entityfields/condition/valueProcess.js b/entity/DuplicateScanConditionConfig_entity/entityfields/condition/valueProcess.js
index a69cee128a7..395c147d364 100644
--- a/entity/DuplicateScanConditionConfig_entity/entityfields/condition/valueProcess.js
+++ b/entity/DuplicateScanConditionConfig_entity/entityfields/condition/valueProcess.js
@@ -2,8 +2,8 @@ import("system.logging");
 import("system.vars");
 import("system.result");
 
-logging.log("condition -> " + JSON.stringify(vars.get("$field.CONDITION")));
-if(vars.get("$field.CONDITION") == "")
+logging.log("condition -> " + JSON.stringify(vars.get("$this.value")));
+if(vars.get("$this.value") == "")
 {
     let entityToScan = vars.get("$param.EntityToFilter_param");
     logging.log("condition leer neu rein schreiben -> " + entityToScan);
diff --git a/entity/DuplicateScanConditionConfig_entity/entityfields/duplicatescan_id/valueProcess.js b/entity/DuplicateScanConditionConfig_entity/entityfields/duplicatescan_id/valueProcess.js
index 9886fc8456d..37ac7439530 100644
--- a/entity/DuplicateScanConditionConfig_entity/entityfields/duplicatescan_id/valueProcess.js
+++ b/entity/DuplicateScanConditionConfig_entity/entityfields/duplicatescan_id/valueProcess.js
@@ -1,6 +1,6 @@
 import("system.result");
 import("system.vars");
-if(vars.get("$field.DUPLICATESCAN_ID") == "")
+if(vars.get("$this.value") == "")
 {
     result.string(vars.get("$param.DuplicateScanId_param"));
 }
\ No newline at end of file
diff --git a/entity/Offer_entity/entityfields/header/valueProcess.js b/entity/Offer_entity/entityfields/header/valueProcess.js
index 7cdc3a91214..fc4636c8444 100644
--- a/entity/Offer_entity/entityfields/header/valueProcess.js
+++ b/entity/Offer_entity/entityfields/header/valueProcess.js
@@ -3,6 +3,7 @@ import("system.vars");
 import("system.neon");
 import("system.db");
 import("system.util");
+import("Sql_lib");
 
 if(vars.exists("$param.OfferHeader_param") && vars.get("$param.OfferHeader_param")) 
     result.string(vars.get("$param.OfferHeader_param"));
@@ -15,6 +16,6 @@ else if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
 
 if (vars.get("$field.ChoosenTEXHeader") != "")
 {
-    var binaryId      = db.cell("select ID from ASYS_BINARIES where ROW_ID = '" + vars.get("$field.ChoosenTEXHeader") + "'", "_____SYSTEMALIAS");
-    result.string(util.decodeBase64String(db.getBinaryContent(binaryId, "_____SYSTEMALIAS")));
+    var binaryId      = db.cell("select ID from ASYS_BINARIES where ROW_ID = '" + vars.get("$field.ChoosenTEXHeader") + "'", SqlUtils.getSystemAlias());
+    result.string(util.decodeBase64String(db.getBinaryContent(binaryId, SqlUtils.getSystemAlias())));
 }
\ No newline at end of file
diff --git a/entity/PermissionDetail_entity/entityfields/role/valueProcess.js b/entity/PermissionDetail_entity/entityfields/role/valueProcess.js
index 0f3e4521b07..d67b588f692 100644
--- a/entity/PermissionDetail_entity/entityfields/role/valueProcess.js
+++ b/entity/PermissionDetail_entity/entityfields/role/valueProcess.js
@@ -8,7 +8,7 @@ var role = "";
 if(vars.exists("$param.RoleTitle_param") && (recordstate == neon.OPERATINGSTATE_NEW)) {
     role = vars.get("$param.RoleTitle_param");
 } else {
-    role = vars.get("$field.ROLE");
+    role = vars.get("$this.value");
 }
 
 result.string(role);
\ No newline at end of file
diff --git a/entity/Person_entity/entityfields/address_id/valueProcess.js b/entity/Person_entity/entityfields/address_id/valueProcess.js
index b889cabd696..6d1c222dd7e 100644
--- a/entity/Person_entity/entityfields/address_id/valueProcess.js
+++ b/entity/Person_entity/entityfields/address_id/valueProcess.js
@@ -1,14 +1,14 @@
-import("system.result");
-import("system.vars");
-import("StandardObject_lib");
-
-//  Check if the standard address is already set.
-if (!vars.get("$field.ADDRESS_ID")) 
-{
-    var possibleStandardAddressID = new StandardObject("Address", null, "Person", vars.get("$field.PERSONID"))
-        .onPersonValueChange(vars.get("$field.ORGANISATION_ID"));
-
-    // If a possible standard addrss was found it should get applied to the field.
-    if (possibleStandardAddressID)
-        result.string(possibleStandardAddressID);
+import("system.result");
+import("system.vars");
+import("StandardObject_lib");
+
+//  Check if the standard address is already set.
+if (!vars.get("$this.value")) 
+{
+    var possibleStandardAddressID = new StandardObject("Address", null, "Person", vars.get("$field.PERSONID"))
+        .onPersonValueChange(vars.get("$field.ORGANISATION_ID"));
+
+    // If a possible standard addrss was found it should get applied to the field.
+    if (possibleStandardAddressID)
+        result.string(possibleStandardAddressID);
 }
\ No newline at end of file
diff --git a/entity/Prod2prod_entity/entityfields/quantity/valueProcess.js b/entity/Prod2prod_entity/entityfields/quantity/valueProcess.js
index 1adf62b3fab..58ce03cbd18 100644
--- a/entity/Prod2prod_entity/entityfields/quantity/valueProcess.js
+++ b/entity/Prod2prod_entity/entityfields/quantity/valueProcess.js
@@ -2,7 +2,7 @@ import("system.vars");
 import("system.result");
 import("system.neon");
 
-if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && !vars.get("$field.QUANTITY"))
+if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$this.value") == null)
 {
     result.string("1");
 }
\ No newline at end of file
-- 
GitLab