From 4a41b36b0b39c06b16f13418e2e13e7a4edfa414 Mon Sep 17 00:00:00 2001
From: Benjamin Ulrich <b.ulrich@adito.de>
Date: Wed, 25 Aug 2021 09:18:41 +0000
Subject: [PATCH] =?UTF-8?q?[Projekt:=20xRM-Sales][TicketNr.:=201086441][Ex?=
 =?UTF-8?q?ception=20beim=20=C3=96ffnen=20einer=20Firma]?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 entity/Organisation_entity/Organisation_entity.aod            | 2 +-
 .../turnovers/children/contactid_param/valueProcess.js        | 4 ----
 .../turnovers/children/contactids_param/valueProcess.js       | 4 ++++
 entity/Turnover_entity/initFilterProcess.js                   | 4 ++--
 .../process.js                                                | 2 ++
 5 files changed, 9 insertions(+), 7 deletions(-)
 delete mode 100644 entity/Organisation_entity/entityfields/turnovers/children/contactid_param/valueProcess.js
 create mode 100644 entity/Organisation_entity/entityfields/turnovers/children/contactids_param/valueProcess.js

diff --git a/entity/Organisation_entity/Organisation_entity.aod b/entity/Organisation_entity/Organisation_entity.aod
index 2ceff6d014..645167af39 100644
--- a/entity/Organisation_entity/Organisation_entity.aod
+++ b/entity/Organisation_entity/Organisation_entity.aod
@@ -1323,7 +1323,7 @@
       <children>
         <entityParameter>
           <name>ContactIds_param</name>
-          <valueProcess>%aditoprj%/entity/Organisation_entity/entityfields/turnovers/children/contactid_param/valueProcess.js</valueProcess>
+          <valueProcess>%aditoprj%/entity/Organisation_entity/entityfields/turnovers/children/contactids_param/valueProcess.js</valueProcess>
         </entityParameter>
       </children>
     </entityConsumer>
diff --git a/entity/Organisation_entity/entityfields/turnovers/children/contactid_param/valueProcess.js b/entity/Organisation_entity/entityfields/turnovers/children/contactid_param/valueProcess.js
deleted file mode 100644
index 7b6137b4d1..0000000000
--- a/entity/Organisation_entity/entityfields/turnovers/children/contactid_param/valueProcess.js
+++ /dev/null
@@ -1,4 +0,0 @@
-import("system.vars");
-import("system.result");
-
-result.string(vars.get("$field.CONTACTID"));
\ No newline at end of file
diff --git a/entity/Organisation_entity/entityfields/turnovers/children/contactids_param/valueProcess.js b/entity/Organisation_entity/entityfields/turnovers/children/contactids_param/valueProcess.js
new file mode 100644
index 0000000000..3fc1cfa96d
--- /dev/null
+++ b/entity/Organisation_entity/entityfields/turnovers/children/contactids_param/valueProcess.js
@@ -0,0 +1,4 @@
+import("system.vars");
+import("system.result");
+
+result.string(JSON.stringify([vars.get("$field.CONTACTID")]));
\ No newline at end of file
diff --git a/entity/Turnover_entity/initFilterProcess.js b/entity/Turnover_entity/initFilterProcess.js
index 3d13a60e2f..b5555d1a97 100644
--- a/entity/Turnover_entity/initFilterProcess.js
+++ b/entity/Turnover_entity/initFilterProcess.js
@@ -6,8 +6,8 @@ import("Keyword_lib");
 import("KeywordRegistry_basic");
 import("system.result");
 
-var contactIds = vars.get("$param.ContactIds_param");
-var salesprojectId = vars.get("$param.SalesprojectIdDynamicChart_param");
+var contactIds = vars.exists("$param.ContactIds_param") ? vars.get("$param.ContactIds_param") : false;
+var salesprojectId = vars.exists("$param.SalesprojectIdDynamicChart_param") ? vars.get("$param.SalesprojectIdDynamicChart_param") : false;
 
 if(contactIds || salesprojectId)
 {
diff --git a/process/TransferSalesprojectPhaseDefinitionToChecklist_serverProcess/process.js b/process/TransferSalesprojectPhaseDefinitionToChecklist_serverProcess/process.js
index 4587f5ee98..4b33154216 100644
--- a/process/TransferSalesprojectPhaseDefinitionToChecklist_serverProcess/process.js
+++ b/process/TransferSalesprojectPhaseDefinitionToChecklist_serverProcess/process.js
@@ -10,6 +10,8 @@ var cols = ["TITLE", "DESCRIPTION", "COND", "CONTEXT", "AUTOPROBABILITY"];
 
 salesprojectPhaseDefs.forEach(function([checklistId, phase, description, autoprobability]){
     let filterCond =  "{\"entity\":\"Salesproject_entity\",\"filter\":{\"type\":\"group\",\"operator\":\"AND\",\"childs\":[{\"type\":\"row\",\"name\":\"PHASE\",\"operator\":\"EQUAL\",\"value\":\"" + KeywordUtils.getViewValue($KeywordRegistry.salesprojectPhase(), phase) + "\",\"key\":\"" + phase + "\",\"contenttype\":\"TEXT\"}]}}";
+    description = description || translate.text("Checklist"); //avoid null values
+
     let vals = [description, description, filterCond, "Salesproject", autoprobability];
     let cond = newWhere("CHECKLIST.CHECKLISTID", checklistId).toString();
     updates.push([table, cols, null, vals, cond]);
-- 
GitLab