From 2e1b5bf463d65daa653ec0f4f2a7bf62f0f893d8 Mon Sep 17 00:00:00 2001
From: Daniel Tran <d.tran@adito.de>
Date: Fri, 5 Mar 2021 14:25:16 +0000
Subject: [PATCH] =?UTF-8?q?Cm=20dt=201074525=20kampagnenteilnehmer=20hinzu?=
 =?UTF-8?q?f=C3=BCgen?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../addparticipants/stateProcess.js           |  9 ++++++-
 .../entityfields/campaign_id/onValidation.js  | 27 +++++++++++--------
 2 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/entity/CampaignAddParticipants_entity/entityfields/addparticipants/stateProcess.js b/entity/CampaignAddParticipants_entity/entityfields/addparticipants/stateProcess.js
index 8271cfcda5..c85f7e47be 100644
--- a/entity/CampaignAddParticipants_entity/entityfields/addparticipants/stateProcess.js
+++ b/entity/CampaignAddParticipants_entity/entityfields/addparticipants/stateProcess.js
@@ -3,13 +3,20 @@ import("system.result");
 import("system.vars");
 
 if (vars.get("$sys.validationerrors"))
+{
     result.string(neon.COMPONENTSTATE_DISABLED);
-else
+}
+else if(vars.get("$field.campaignparticipantContactIds") != null && vars.get("$field.campaignparticipantContactIds") != "")
 {
     var contactCount = JSON.parse(vars.get("$field.campaignparticipantContactIds")).length;
+    
     if (contactCount == 0)
+    {
         result.string(neon.COMPONENTSTATE_DISABLED);
+    }
     else
+    {
         result.string(neon.COMPONENTSTATE_EDITABLE);
+    }
 }
     
\ No newline at end of file
diff --git a/entity/CampaignAddParticipants_entity/entityfields/campaign_id/onValidation.js b/entity/CampaignAddParticipants_entity/entityfields/campaign_id/onValidation.js
index c84027b8fe..c596003e42 100644
--- a/entity/CampaignAddParticipants_entity/entityfields/campaign_id/onValidation.js
+++ b/entity/CampaignAddParticipants_entity/entityfields/campaign_id/onValidation.js
@@ -3,17 +3,22 @@ import("system.result");
 import("Sql_lib");
 import("system.translate");
 
-let participants = JSON.parse(vars.get("$param.campaignParticipantsRowIds_param"));
-if(participants.length > 0)
+
+if (vars.get("$param.campaignParticipantsRowIds_param") != null && vars.get("$param.campaignParticipantsRowIds_param") != "")
 {
-    let thisParticipantCount = newSelect("count('')").from("CAMPAIGNPARTICIPANT")
-        .where("CAMPAIGNPARTICIPANT.CAMPAIGN_ID", vars.get("$field.CAMPAIGN_ID"))
-        .and(
-            "CAMPAIGNPARTICIPANT.CONTACT_ID",
-            participants,
-            SqlBuilder.IN()
-        ).cell();
+    let participants = JSON.parse(vars.get("$param.campaignParticipantsRowIds_param"));
+
+    if(participants.length > 0)
+    {
+        let thisParticipantCount = newSelect("COUNT(*)")
+                                        .from("CAMPAIGNPARTICIPANT")
+                                        .where("CAMPAIGNPARTICIPANT.CAMPAIGN_ID", vars.get("$field.CAMPAIGN_ID"))
+                                        .and("CAMPAIGNPARTICIPANT.CONTACT_ID", participants, SqlBuilder.IN())
+                                        .cell();
 
-    if(parseInt(thisParticipantCount) > 0)
-        result.string(translate.text("Participant is already participating"));
+        if(parseInt(thisParticipantCount) > 0)
+        {
+            result.string(translate.text("Participant is already participating"));
+        }
+    }
 }
-- 
GitLab