Skip to content
Snippets Groups Projects
Commit 1e1c481f authored by Johannes Goderbauer's avatar Johannes Goderbauer
Browse files

Merge branch '1043987-wrong-participant-couting' into '2020.0'

1043987 wrong participant couting

See merge request xrm/basic!132

(cherry picked from commit 7c5f54e7)

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.
parent ce110534
No related branches found
No related tags found
No related merge requests found
Showing
with 30 additions and 14 deletions
......@@ -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>
......
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
......@@ -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
......@@ -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)
......
......@@ -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
{
......
......@@ -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>
......
......@@ -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
......@@ -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
......@@ -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>
......
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
......@@ -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
......@@ -174,6 +174,7 @@
</entityProvider>
<entityConsumer>
<name>CampaignParticipants</name>
<refreshParent v="false" />
<selectionMode>MULTI</selectionMode>
<dependency>
<name>dependency</name>
......
......@@ -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")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment