diff --git a/entity/CampaignAddParticipants_entity/entityfields/isoperationvalid/valueProcess.js b/entity/CampaignAddParticipants_entity/entityfields/isoperationvalid/valueProcess.js index c0689ca0aa2ecf419c001d1461c673d2b5f076d7..fb3bf4d5aec344a39b2a65b289d770d726029469 100644 --- a/entity/CampaignAddParticipants_entity/entityfields/isoperationvalid/valueProcess.js +++ b/entity/CampaignAddParticipants_entity/entityfields/isoperationvalid/valueProcess.js @@ -96,23 +96,27 @@ if(selectedCampaignId != '') { messageString = translate.text("All selected participants already are in the campaign"); } - else if(hasStepEnoughSlots(countValidParticipantsToAdd)) - { - messageString = translate.withArguments("%0/%1 participant(s) will be added to the selected campaign step", [countValidParticipantsToAdd, countParticipantsToAdd]); - resultValue = "true"; - } else { - messageString = translate.withArguments("Not enough slots for %0/%1 participant(s)", [countValidParticipantsToAdd, countParticipantsToAdd]); + let excess = getParticipantExcess(countValidParticipantsToAdd); + if (excess > 0) + { + messageString = translate.withArguments("Not enough slots for %0/%1 participant(s)", [excess, countParticipantsToAdd]); + } + else + { + messageString = translate.withArguments("%0/%1 participant(s) will be added to the selected campaign step", [countValidParticipantsToAdd, countParticipantsToAdd]); + resultValue = "true"; + } } neon.setFieldValue("$field.campaignParticipantMessage", messageString); result.string(resultValue); } -function hasStepEnoughSlots(pCountToAdd) +function getParticipantExcess (pCountToAdd) { let currentParticipants = CampaignUtils.getParticipantCountForStep(selectedCampaignStepId) let maxParticipants = CampaignUtils.getMaxParticipantCountForStep(selectedCampaignStepId) - return (parseInt(currentParticipants) + parseInt(pCountToAdd)) <= maxParticipants; + return (parseInt(currentParticipants) + parseInt(pCountToAdd)) - maxParticipants; } \ No newline at end of file