diff --git a/entity/CampaignAddParticipants_entity/recordcontainers/jdito/onInsert.js b/entity/CampaignAddParticipants_entity/recordcontainers/jdito/onInsert.js index 8e30f7b7188c852aa11b7d1bbb20963ed6c570a1..12f66113e1ae398eec2ebdb19e6f337bbee03500 100644 --- a/entity/CampaignAddParticipants_entity/recordcontainers/jdito/onInsert.js +++ b/entity/CampaignAddParticipants_entity/recordcontainers/jdito/onInsert.js @@ -73,12 +73,11 @@ function _handleRowIds(pParticipantRowIds) let oldSteps = db.table(SqlCondition.begin() .orIn("CAMPAIGNPARTICIPANT.CAMPAIGNPARTICIPANTID", pParticipantRowIds) - .orIn("CAMPAIGNPARTICIPANT.CONTACT_ID", pParticipantRowIds) .buildSql("select CAMPAIGNPARTICIPANTID, CAMPAIGNSTEP_ID from CAMPAIGNPARTICIPANT", "1=2") ); oldSteps.forEach(function (step) { - + this[step[0]] = step[1]; }, oldStepIds); } else @@ -101,9 +100,8 @@ function _handleRowIds(pParticipantRowIds) if(isUpdate == "true") { - let oldCampaignStepId = ""; + let oldCampaignStepId = oldStepIds[pParticipantRowIds[participant]] || ""; let updatedValues = [newCampaignStepId, - oldCampaignStepId, vars.get("$sys.user"), vars.get("$sys.date")]; @@ -144,7 +142,6 @@ function _handleRowIds(pParticipantRowIds) } else db.inserts(statementArray); - if(logArray.length > 0) db.inserts(logArray); } diff --git a/entity/CampaignParticipantChart_entity/recordcontainers/jdito/contentProcess.js b/entity/CampaignParticipantChart_entity/recordcontainers/jdito/contentProcess.js index 3d6816c656ace8a7fc942212f1f4b28e8f1d9a6a..c0de8da56a189d7fc6347b135c79685f7a76468d 100644 --- a/entity/CampaignParticipantChart_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/CampaignParticipantChart_entity/recordcontainers/jdito/contentProcess.js @@ -9,7 +9,10 @@ var campaignId = vars.get("$param.CampaignId_param"); var sqlSelect = "select CAMPAIGNSTEPID, CAMPAIGNSTEP.NAME, count(distinct CAMPAIGNPARTICIPANTID), MAXPARTICIPANTS, count(distinct CAMPAIGNPARTICIPANTLOG.CAMPAIGNPARTICIPANT_ID) \n\ from CAMPAIGNSTEP \n\ left join CAMPAIGNPARTICIPANT on CAMPAIGNSTEPID = CAMPAIGNPARTICIPANT.CAMPAIGNSTEP_ID \n\ - left join CAMPAIGNPARTICIPANTLOG on CAMPAIGNSTEPID = CAMPAIGNPARTICIPANTLOG.PREVIOUS_CAMPAIGNSTEP_ID"; + left join CAMPAIGNPARTICIPANTLOG on CAMPAIGNSTEPID = CAMPAIGNPARTICIPANTLOG.PREVIOUS_CAMPAIGNSTEP_ID and CAMPAIGNPARTICIPANTLOG.CAMPAIGNSTEP_ID != CAMPAIGNPARTICIPANTLOG.PREVIOUS_CAMPAIGNSTEP_ID"; + //Participated: counts all distinct CAMPAIGNPARTICIPANT_IDs from logs where the PREVIOUS_CAMPAIGNSTEP_ID is the id of the campaign step. Logs where + //the new CAMPAIGNSTEP_ID is the same as the PREVIOUS_CAMPAIGNSTEP_ID are not counted. This does not check if the SORTING is correct. + var sqlGroupOrderBy = "group by CAMPAIGNSTEPID, CAMPAIGNSTEP.NAME, MAXPARTICIPANTS, CAMPAIGNSTEP.SORTING order by CAMPAIGNSTEP.SORTING"; var sqlQuery = SqlCondition.begin() diff --git a/process/Attribute_lib/process.js b/process/Attribute_lib/process.js index 7d02717f1fdc522ebe9e7ee9470a94a5e36f92dd..3236ea76d543e02a6e4c148dca4b539816eb0b14 100644 --- a/process/Attribute_lib/process.js +++ b/process/Attribute_lib/process.js @@ -873,6 +873,8 @@ function AttributeUsageUtil () {} */ AttributeUsageUtil.insertChildrenUsages = function (pAttributeId, pObjectType) { + if (!pAttributeId) + return; var table = "AB_ATTRIBUTEUSAGE"; var columns = ["AB_ATTRIBUTEUSAGEID", "AB_ATTRIBUTE_ID", "OBJECT_TYPE"]; var types = db.getColumnTypes(table, columns); @@ -914,7 +916,7 @@ AttributeUsageUtil.insertChildrenUsages = function (pAttributeId, pObjectType) */ AttributeUsageUtil.updateChildrenUsages = function (pAttributeId, pOldObjectType, pNewObjectType) { - if (!pNewObjectType) + if (!pNewObjectType || !pAttributeId) return; var table = "AB_ATTRIBUTEUSAGE";