diff --git a/entity/CampaignAddParticipants_entity/entityfields/isoperationvalid/valueProcess.js b/entity/CampaignAddParticipants_entity/entityfields/isoperationvalid/valueProcess.js
index 7232e9b7806fe94ddb279962715a35820ed89a1b..77b64092bdb0a66d9dab7725677aef4290e5d74d 100644
--- a/entity/CampaignAddParticipants_entity/entityfields/isoperationvalid/valueProcess.js
+++ b/entity/CampaignAddParticipants_entity/entityfields/isoperationvalid/valueProcess.js
@@ -1,3 +1,4 @@
+import("Sql_lib");
 import("Campaign_lib");
 import("system.result");
 import("system.translate");
@@ -29,7 +30,7 @@ if(selectedCampaignId != '')
     var countParticipantsAlreadyInCampaign = 0;
     var countParticipantsToAdd = 0;
     var countValidParticipantsToAdd = 0;
-    var whereCondition = "";
+    var whereCondition = SqlCondition.begin();
     var rowIdsComparisonField = "";
         
     //if theres a selection, we have to use it, otherwise use the condition
@@ -47,15 +48,15 @@ if(selectedCampaignId != '')
          */
         if(isUpdate == "true")
         {
-            rowIdsComparisonField = "CAMPAIGNPARTICIPANT.CAMPAIGNPARTICIPANTID";
-            whereCondition = "CAMPAIGNPARTICIPANT.CAMPAIGNSTEP_ID = '" + selectedCampaignStepId + "'";
+            whereCondition.andPrepare("CAMPAIGNPARTICIPANT.CAMPAIGNSTEP_ID", selectedCampaignStepId);
+            whereCondition.andIn("CAMPAIGNPARTICIPANT.CAMPAIGNPARTICIPANTID", selectionRowIds)
         }
         else
         {
-            rowIdsComparisonField = "CAMPAIGNPARTICIPANT.CONTACT_ID";
-            whereCondition = "CAMPAIGNPARTICIPANT.CAMPAIGN_ID = '" + selectedCampaignId + "'";
+            whereCondition.andPrepare("CAMPAIGNPARTICIPANT.CAMPAIGN_ID", selectedCampaignId);
+            whereCondition.andIn("CAMPAIGNPARTICIPANT.CONTACT_ID", selectionRowIds)
         }
-        countParticipantsAlreadyInCampaign = CampaignUtils.GetParticipantsAlreadyAddedCountByRowId(whereCondition, rowIdsComparisonField, selectionRowIds);
+        countParticipantsAlreadyInCampaign = CampaignUtils.GetParticipantsCountByCondition(whereCondition);
     }
     else
     {
@@ -80,11 +81,12 @@ if(selectedCampaignId != '')
          * step because one participant can be in a campaign just once.
          */
         if(isUpdate == "true")
-            whereCondition = "CAMPAIGNPARTICIPANT.CAMPAIGNSTEP_ID = '" + selectedCampaignStepId + "'";
+            whereCondition.andPrepare("CAMPAIGNPARTICIPANT.CAMPAIGNSTEP_ID", selectedCampaignStepId);
         else
-            whereCondition = "CAMPAIGNPARTICIPANT.CAMPAIGN_ID = '" + selectedCampaignId + "'";
+            whereCondition.andPrepare("CAMPAIGNPARTICIPANT.CAMPAIGN_ID", selectedCampaignId);
 
-        countParticipantsAlreadyInCampaign = CampaignUtils.GetParticipantsAlreadyAddedCountByCondition(whereCondition, participantCondition, useRightJoinToGetOrgs);
+        whereCondition.and(participantCondition);
+        countParticipantsAlreadyInCampaign = CampaignUtils.GetParticipantsAlreadyAddedCountByCondition(whereCondition, useRightJoinToGetOrgs);
     }
     countValidParticipantsToAdd = countParticipantsToAdd - countParticipantsAlreadyInCampaign;
     
diff --git a/process/Campaign_lib/process.js b/process/Campaign_lib/process.js
index d281d437b38c493690fd9ae0ca7d3ca67482c265..a97b5a1f62f752c663c213b2efbcf0f23f9586e4 100644
--- a/process/Campaign_lib/process.js
+++ b/process/Campaign_lib/process.js
@@ -298,34 +298,28 @@ CampaignUtils.checkforCommRestrictions = function(contactid, campaignstepid)
                 .buildSql("select MEDIUM from CAMPAIGNSTEP join COMMRESTRICTION on MEDIUM = STEPMEDIUM", "1=2"));
 }
 
-CampaignUtils.GetParticipantsAlreadyAddedCountByRowId = function(pWhereCondition, pRowIdsComparisonField, pParticipantRowIds)
-{
-    let rowIdsAsRay = _CampaignUtils._convertToSqlValuesList(pParticipantRowIds);
-    
-    let query = "SELECT COUNT(*) FROM CAMPAIGNPARTICIPANT"
-    + " where " + pWhereCondition + " AND"
-    + " " + pRowIdsComparisonField + " IN " + rowIdsAsRay;
-
-    return db.cell(query)
+/**
+ * @param {SqlCondition} pWhereCondition an SqlCondition object containing a condition to select from campaignparticipant
+ * @return {String} the counts (as string)
+ */
+CampaignUtils.GetParticipantsCountByCondition = function(pWhereCondition)
+{   
+    return db.cell(pWhereCondition.buildSql("SELECT COUNT(*) FROM CAMPAIGNPARTICIPANT", "1=2"));
 }
 
-CampaignUtils.GetParticipantsAlreadyAddedCountByCondition = function(pWhereCondition, pCondition, pRightJoinContacts)
+CampaignUtils.GetParticipantsAlreadyAddedCountByCondition = function(pWhereCondition, pRightJoinContacts)
 {
-    let query = "select count(*) from PERSON"
+    let selectSql = "select count(*) from PERSON"
     
     if(pRightJoinContacts == "true")
-        query += " right"
+        selectSql += " right"
     
-    query += " join CONTACT on (CONTACT.PERSON_ID = PERSON.PERSONID)"
+    selectSql += " join CONTACT on (CONTACT.PERSON_ID = PERSON.PERSONID)"
     + " join ORGANISATION on (ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID)"
     + " left join ADDRESS on (ADDRESS.ADDRESSID = CONTACT.ADDRESS_ID)"
     + " left join CAMPAIGNPARTICIPANT on CAMPAIGNPARTICIPANT.CONTACT_ID = CONTACT.CONTACTID"
-    + " where " + pWhereCondition
 
-    if(pCondition != "")
-        query += " and " + pCondition;
-    
-    return db.cell(query)
+    return db.cell(pWhereCondition.buildSql(selectSql, "1=2"))
 }
 
 CampaignUtils.GetContactIdsNotInCampaignByRowIds = function(pCampaignId, pParticipantRowIds)