From 1e1c481f556288e08d890d465194b65d89ff71f0 Mon Sep 17 00:00:00 2001 From: Johannes Goderbauer <j.goderbauer@adito.de> Date: Fri, 20 Mar 2020 08:30:56 +0000 Subject: [PATCH] Merge branch '1043987-wrong-participant-couting' into '2020.0' 1043987 wrong participant couting See merge request xrm/basic!132 (cherry picked from commit 7c5f54e758fa4a0200cf35a877bb63055495280c) 1ffcd3ad Zwischencommit. ded86f37 merged 2020.0 into 1043987-wrong-participant-couting 9dcbb756 merged 2020.0 into 1043987-wrong-participant-couting 0c9cc14d #1043987 - Added validation of "$this.value" in if condition. dc31c7c1 #1043987: Disabled line in changelog.xml for example data. --- .../CampaignAddParticipants_entity.aod | 3 +++ .../displayValueProcess.js | 3 ++- .../entityfields/isoperationvalid/valueProcess.js | 4 ++-- .../recordcontainers/jdito/onInsert.js | 10 +++++----- .../entityfields/countparticipants/valueProcess.js | 2 +- .../CampaignParticipant_entity.aod | 3 +++ .../displayValueProcess.js | 2 +- .../setsteptoparticipantselection/onActionProcess.js | 1 - entity/CampaignStep_entity/CampaignStep_entity.aod | 1 + .../entityfields/campaignstepid/valueProcess.js | 7 +++++++ .../currentmaxparticipantsinfo/valueProcess.js | 2 +- entity/Campaign_entity/Campaign_entity.aod | 1 + process/Campaign_lib/process.js | 5 +++-- 13 files changed, 30 insertions(+), 14 deletions(-) create mode 100644 entity/CampaignStep_entity/entityfields/campaignstepid/valueProcess.js diff --git a/entity/CampaignAddParticipants_entity/CampaignAddParticipants_entity.aod b/entity/CampaignAddParticipants_entity/CampaignAddParticipants_entity.aod index 6f7b018b1a..9bf8498007 100644 --- a/entity/CampaignAddParticipants_entity/CampaignAddParticipants_entity.aod +++ b/entity/CampaignAddParticipants_entity/CampaignAddParticipants_entity.aod @@ -4,6 +4,9 @@ <majorModelMode>DISTRIBUTED</majorModelMode> <documentation>%aditoprj%/entity/CampaignAddParticipants_entity/documentation.adoc</documentation> <title>Add participants to Campaign</title> + <siblings> + <element>CampaignParticipant_entity</element> + </siblings> <onValidation>%aditoprj%/entity/CampaignAddParticipants_entity/onValidation.js</onValidation> <recordContainer>jdito</recordContainer> <entityFields> diff --git a/entity/CampaignAddParticipants_entity/entityfields/campaignstepcurrentparticipantcount/displayValueProcess.js b/entity/CampaignAddParticipants_entity/entityfields/campaignstepcurrentparticipantcount/displayValueProcess.js index 3fe2184695..3fdaf507cf 100644 --- a/entity/CampaignAddParticipants_entity/entityfields/campaignstepcurrentparticipantcount/displayValueProcess.js +++ b/entity/CampaignAddParticipants_entity/entityfields/campaignstepcurrentparticipantcount/displayValueProcess.js @@ -1,5 +1,6 @@ +import("system.logging"); import("system.result"); import("system.vars"); import("Campaign_lib"); -result.string(CampaignUtils.getParticipantCountForStep(vars.get("$field.CAMPAIGNSTEP_ID"))); \ No newline at end of file +result.string(CampaignUtils.getParticipantCountForStep(vars.get("$field.CAMPAIGNSTEP_ID"), vars.get("$field.CAMPAIGN_ID"))); \ No newline at end of file diff --git a/entity/CampaignAddParticipants_entity/entityfields/isoperationvalid/valueProcess.js b/entity/CampaignAddParticipants_entity/entityfields/isoperationvalid/valueProcess.js index f4d6e6e52b..47fb5627a5 100644 --- a/entity/CampaignAddParticipants_entity/entityfields/isoperationvalid/valueProcess.js +++ b/entity/CampaignAddParticipants_entity/entityfields/isoperationvalid/valueProcess.js @@ -117,8 +117,8 @@ if(selectedCampaignId != '') function getParticipantExcess (pCountToAdd) { - let currentParticipants = CampaignUtils.getParticipantCountForStep(selectedCampaignStepId) - let maxParticipants = CampaignUtils.getMaxParticipantCountForStep(selectedCampaignStepId) + let currentParticipants = CampaignUtils.getParticipantCountForStep(selectedCampaignStepId, vars.get("$field.CAMPAIGN_ID")); + let maxParticipants = CampaignUtils.getMaxParticipantCountForStep(selectedCampaignStepId, vars.get("$field.CAMPAIGN_ID")); return (parseInt(currentParticipants) + parseInt(pCountToAdd)) - maxParticipants; } \ No newline at end of file diff --git a/entity/CampaignAddParticipants_entity/recordcontainers/jdito/onInsert.js b/entity/CampaignAddParticipants_entity/recordcontainers/jdito/onInsert.js index 95c8bcbdf7..44bfa0e717 100644 --- a/entity/CampaignAddParticipants_entity/recordcontainers/jdito/onInsert.js +++ b/entity/CampaignAddParticipants_entity/recordcontainers/jdito/onInsert.js @@ -24,7 +24,7 @@ if(participantRowIds != null && participantRowIds.length > 0) if(isUpdate == "false") contactIdsToHandle = CampaignUtils.GetContactIdsNotInCampaignByRowIds(campaignId, participantRowIds); - _handleRowIds(contactIdsToHandle); + _handleRowIds(contactIdsToHandle, campaignId); } else { @@ -60,10 +60,10 @@ function _handleCondition(pCampaignId, pTargetTableName, pCondition) else contactIdsToHandle = CampaignUtils.GetContactIdsNotInCampaignByCondition(pCampaignId, pCondition, useRightJoinToGetOrgs); - _handleRowIds(contactIdsToHandle); + _handleRowIds(contactIdsToHandle, pCampaignId); } -function _handleRowIds(pParticipantRowIds) +function _handleRowIds(pParticipantRowIds, pCampaignId) { var oldStepIds = {}; if(isUpdate == "true") @@ -72,10 +72,10 @@ function _handleRowIds(pParticipantRowIds) "USER_EDIT", "DATE_EDIT" ]; - let oldSteps = newSelect("CAMPAIGNPARTICIPANTID, CAMPAIGNSTEP_ID") .from("CAMPAIGNPARTICIPANT") - .whereIfSet("CAMPAIGNPARTICIPANT.CAMPAIGNPARTICIPANTID", pParticipantRowIds, SqlBuilder.IN()) + .whereIfSet("CAMPAIGNPARTICIPANT.CONTACT_ID", pParticipantRowIds, SqlBuilder.IN()) + .and("CAMPAIGNPARTICIPANT.CAMPAIGN_ID", pCampaignId) .table(true); oldSteps.forEach(function (step) diff --git a/entity/CampaignCost_entity/entityfields/countparticipants/valueProcess.js b/entity/CampaignCost_entity/entityfields/countparticipants/valueProcess.js index 6952bc19fb..b717a89362 100644 --- a/entity/CampaignCost_entity/entityfields/countparticipants/valueProcess.js +++ b/entity/CampaignCost_entity/entityfields/countparticipants/valueProcess.js @@ -4,7 +4,7 @@ import("Campaign_lib"); if (vars.get("$field.CAMPAIGNSTEP_ID")) { - result.string(CampaignUtils.getParticipantCountForStep(vars.get("$field.CAMPAIGNSTEP_ID"))); + result.string(CampaignUtils.getParticipantCountForStep(vars.get("$field.CAMPAIGNSTEP_ID"), vars.get("$field.CAMPAIGN_ID"))); } else { diff --git a/entity/CampaignParticipant_entity/CampaignParticipant_entity.aod b/entity/CampaignParticipant_entity/CampaignParticipant_entity.aod index e1d7172fd0..0572cb1c00 100644 --- a/entity/CampaignParticipant_entity/CampaignParticipant_entity.aod +++ b/entity/CampaignParticipant_entity/CampaignParticipant_entity.aod @@ -96,6 +96,7 @@ </entityField> <entityConsumer> <name>CampaignsConsumer</name> + <refreshParent v="true" /> <dependency> <name>dependency</name> <entityName>Campaign_entity</entityName> @@ -142,6 +143,7 @@ </entityConsumer> <entityConsumer> <name>CampaignSteps</name> + <refreshParent v="true" /> <dependency> <name>dependency</name> <entityName>CampaignStep_entity</entityName> @@ -229,6 +231,7 @@ <dbRecordContainer> <name>ParticipantsDbRecordContainer</name> <alias>Data_alias</alias> + <hasDependentRecords v="true" /> <conditionProcess>%aditoprj%/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/conditionProcess.js</conditionProcess> <onDBInsert>%aditoprj%/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/onDBInsert.js</onDBInsert> <linkInformation> diff --git a/entity/CampaignParticipant_entity/entityfields/campaignstepcurrentparticipantcount/displayValueProcess.js b/entity/CampaignParticipant_entity/entityfields/campaignstepcurrentparticipantcount/displayValueProcess.js index 3fe2184695..d4be69539f 100644 --- a/entity/CampaignParticipant_entity/entityfields/campaignstepcurrentparticipantcount/displayValueProcess.js +++ b/entity/CampaignParticipant_entity/entityfields/campaignstepcurrentparticipantcount/displayValueProcess.js @@ -2,4 +2,4 @@ import("system.result"); import("system.vars"); import("Campaign_lib"); -result.string(CampaignUtils.getParticipantCountForStep(vars.get("$field.CAMPAIGNSTEP_ID"))); \ No newline at end of file +result.string(CampaignUtils.getParticipantCountForStep(vars.get("$field.CAMPAIGNSTEP_ID"), vars.get("$field.CAMPAIGN_ID"))); \ No newline at end of file diff --git a/entity/CampaignParticipant_entity/entityfields/filterviewactiongroup/children/setsteptoparticipantselection/onActionProcess.js b/entity/CampaignParticipant_entity/entityfields/filterviewactiongroup/children/setsteptoparticipantselection/onActionProcess.js index f7f984d937..1537b3bbbc 100644 --- a/entity/CampaignParticipant_entity/entityfields/filterviewactiongroup/children/setsteptoparticipantselection/onActionProcess.js +++ b/entity/CampaignParticipant_entity/entityfields/filterviewactiongroup/children/setsteptoparticipantselection/onActionProcess.js @@ -14,6 +14,5 @@ if(sysSelection.length > 0) //selektierte IDs als Array else { let sysFilter = vars.get("$sys.filter");//todo change name - CampaignUtils.openSetCampaignStepViewByCondition(JSON.stringify(sysFilter), campaignId, campaignStepId); } \ No newline at end of file diff --git a/entity/CampaignStep_entity/CampaignStep_entity.aod b/entity/CampaignStep_entity/CampaignStep_entity.aod index 99019821d9..d9cd9d2ef9 100644 --- a/entity/CampaignStep_entity/CampaignStep_entity.aod +++ b/entity/CampaignStep_entity/CampaignStep_entity.aod @@ -36,6 +36,7 @@ <entityField> <name>CAMPAIGNSTEPID</name> <mandatory v="true" /> + <valueProcess>%aditoprj%/entity/CampaignStep_entity/entityfields/campaignstepid/valueProcess.js</valueProcess> </entityField> <entityField> <name>CAMPAIGN_ID</name> diff --git a/entity/CampaignStep_entity/entityfields/campaignstepid/valueProcess.js b/entity/CampaignStep_entity/entityfields/campaignstepid/valueProcess.js new file mode 100644 index 0000000000..4faa129377 --- /dev/null +++ b/entity/CampaignStep_entity/entityfields/campaignstepid/valueProcess.js @@ -0,0 +1,7 @@ +import("system.util"); +import("system.vars"); +import("system.result"); +import("system.neon"); + +if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$this.value") == null) + result.string(util.getNewUUID()); \ No newline at end of file diff --git a/entity/CampaignStep_entity/entityfields/currentmaxparticipantsinfo/valueProcess.js b/entity/CampaignStep_entity/entityfields/currentmaxparticipantsinfo/valueProcess.js index 4f1a6b3964..86c117c70d 100644 --- a/entity/CampaignStep_entity/entityfields/currentmaxparticipantsinfo/valueProcess.js +++ b/entity/CampaignStep_entity/entityfields/currentmaxparticipantsinfo/valueProcess.js @@ -2,6 +2,6 @@ import("system.result"); import("system.vars"); import("Campaign_lib"); -let currentParticipantsCount = CampaignUtils.getParticipantCountForStep(vars.get("$field.CAMPAIGNSTEPID")); +let currentParticipantsCount = CampaignUtils.getParticipantCountForStep(vars.get("$field.CAMPAIGNSTEPID"), vars.get("$field.CAMPAIGN_ID")); let maxParticipantsStepCount = vars.get("$field.MAXPARTICIPANTS"); result.string(currentParticipantsCount + "/" + maxParticipantsStepCount); \ No newline at end of file diff --git a/entity/Campaign_entity/Campaign_entity.aod b/entity/Campaign_entity/Campaign_entity.aod index 3165e68b88..6060581249 100644 --- a/entity/Campaign_entity/Campaign_entity.aod +++ b/entity/Campaign_entity/Campaign_entity.aod @@ -174,6 +174,7 @@ </entityProvider> <entityConsumer> <name>CampaignParticipants</name> + <refreshParent v="false" /> <selectionMode>MULTI</selectionMode> <dependency> <name>dependency</name> diff --git a/process/Campaign_lib/process.js b/process/Campaign_lib/process.js index 2e1cc2f66a..9d80baee3d 100644 --- a/process/Campaign_lib/process.js +++ b/process/Campaign_lib/process.js @@ -67,11 +67,12 @@ CampaignUtils.getCampaignStepNameById = function(pCampaignStepId) * The current count of participants in the given campaignstep * @return count of participants, 0 if no campaignstep could be found for the id */ -CampaignUtils.getParticipantCountForStep = function(pCampaignStepId) +CampaignUtils.getParticipantCountForStep = function(pCampaignStepId, pCampaignId) { return newSelect("count(*)") .from("CAMPAIGNPARTICIPANT") .whereIfSet("CAMPAIGNPARTICIPANT.CAMPAIGNSTEP_ID", pCampaignStepId) + .and("CAMPAIGNPARTICIPANT.CAMPAIGN_ID", pCampaignId) .cell(true, 0); } @@ -373,7 +374,7 @@ CampaignUtils.GetContactIdsInCampaignByCondition = function(pCampaignId, pCondit // if(pRightJoinContacts == "true") // query += " right" - + query.leftJoin("PERSON", "CONTACT.PERSON_ID = PERSON.PERSONID") .leftJoin("ORGANISATION", "ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID") .leftJoin("ADDRESS", "ADDRESS.ADDRESSID = CONTACT.ADDRESS_ID") -- GitLab