diff --git a/entity/CampaignAddParticipants_entity/recordcontainers/jdito/onInsert.js b/entity/CampaignAddParticipants_entity/recordcontainers/jdito/onInsert.js index 2c0ffca3092ae652832b205a914571efd639f59d..e8edf991ced2e73426ce170fc3f6a06e00cb366c 100644 --- a/entity/CampaignAddParticipants_entity/recordcontainers/jdito/onInsert.js +++ b/entity/CampaignAddParticipants_entity/recordcontainers/jdito/onInsert.js @@ -1,19 +1,25 @@ import("system.vars"); import("system.db"); import("system.util"); +import("Campaign_lib"); var campaignId = vars.getString("$field.CAMPAIGN_ID"); var campaignStepId = vars.getString("$field.CAMPAIGNSTEP_ID"); var participants = JSON.parse(vars.getString("$param.campaignParticipants_param")); -var cols = [ "CAMPAIGNPARTICIPANTID" +var colNamesCampaignParticipantLog = CampaignUtils.getParticipantLogInsertColumnNames(); +var colTypesCampaignParticipantLog = CampaignUtils.getParticipantLogInsertColumnTypes(); + +var colsCampaignParticipant = [ "CAMPAIGNPARTICIPANTID" ,"CONTACT_ID" ,"CAMPAIGN_ID" ,"CAMPAIGNSTEP_ID" ,"USER_NEW" ,"DATE_NEW" ]; -var colTypes = db.getColumnTypes("CAMPAIGNPARTICIPANT", cols); + +var colTypesCampaignParticipant = db.getColumnTypes("CAMPAIGNPARTICIPANT", colsCampaignParticipant); + var insertArray = []; @@ -21,15 +27,18 @@ for (participant in participants) { let campaignParticipantId = util.getNewUUID(); - var vals = [ campaignParticipantId + var valsCampaignParticipant = [ campaignParticipantId , participants[participant] , campaignId , campaignStepId , vars.get("$sys.user") , vars.get("$sys.date") ]; + + var valsCampaignParticipantLog = new Array(campaignId, campaignStepId, participants[participant], campaignParticipantId, vars.get("$sys.user"), vars.get("$sys.date")); - insertArray.push(["CAMPAIGNPARTICIPANT", cols, colTypes, vals]); + insertArray.push(["CAMPAIGNPARTICIPANT", colsCampaignParticipant, colTypesCampaignParticipant, valsCampaignParticipant]); + insertArray.push(["CAMPAIGNPARTICIPANTLOG", colNamesCampaignParticipantLog, colTypesCampaignParticipantLog, valsCampaignParticipantLog]); } db.inserts(insertArray); \ No newline at end of file diff --git a/entity/CampaignParticipant_entity/CampaignParticipant_entity.aod b/entity/CampaignParticipant_entity/CampaignParticipant_entity.aod index 24a2e510c37db9206b01579db4a1da66568ab52e..a049a87b4f9b9c76e146cc8f1e322a089a29dfc6 100644 --- a/entity/CampaignParticipant_entity/CampaignParticipant_entity.aod +++ b/entity/CampaignParticipant_entity/CampaignParticipant_entity.aod @@ -153,6 +153,7 @@ <name>ParticipantsDbRecordContainer</name> <alias>Data_alias</alias> <conditionProcess>%aditoprj%/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/conditionProcess.js</conditionProcess> + <onDBInsert>%aditoprj%/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/onDBInsert.js</onDBInsert> <linkInformation> <linkInformation> <name>12b5bf2e-e376-4c40-9799-fb07961a455d</name> diff --git a/entity/CampaignParticipant_entity/entityfields/campaign_id/valueProcess.js b/entity/CampaignParticipant_entity/entityfields/campaign_id/valueProcess.js index 95645706dce81f2df288e0537ea07523eb99d821..619a4eb3879036407125c0a0f51cf0419a54b1fc 100644 --- a/entity/CampaignParticipant_entity/entityfields/campaign_id/valueProcess.js +++ b/entity/CampaignParticipant_entity/entityfields/campaign_id/valueProcess.js @@ -2,5 +2,8 @@ import("system.neon"); import("system.result"); import("system.vars"); -if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.exists("$param.CampaignId_param") && vars.get("$param.CampaignId_param")) - result.string(vars.get("$param.CampaignId_param")); \ No newline at end of file +if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && + vars.exists("$param.CampaignId_param") && vars.get("$param.CampaignId_param")) + { + result.string(vars.get("$param.CampaignId_param")); + } \ No newline at end of file diff --git a/entity/CampaignParticipant_entity/entityfields/campaignstep_id/displayValueProcess.js b/entity/CampaignParticipant_entity/entityfields/campaignstep_id/displayValueProcess.js index 0bdd6ffe53aaf400d4d3a66bbaa316f2e8709ee2..50b15240cd35c3d097b8449f5652768c9c590473 100644 --- a/entity/CampaignParticipant_entity/entityfields/campaignstep_id/displayValueProcess.js +++ b/entity/CampaignParticipant_entity/entityfields/campaignstep_id/displayValueProcess.js @@ -2,4 +2,4 @@ import("system.vars"); import("system.db"); import("system.result"); -result.string(db.cell("select NAME from CAMPAIGNSTEP where CAMPAIGNSTEPID = '" + vars.get("$field.CAMPAIGNSTEP_ID") + "'")); \ No newline at end of file +result.string(db.cell("select NAME from CAMPAIGNSTEP where CAMPAIGNSTEPID = '" + vars.get("$param.CampaignStepId_param") + "'")); \ No newline at end of file diff --git a/entity/CampaignParticipant_entity/entityfields/campaignstep_id/valueProcess.js b/entity/CampaignParticipant_entity/entityfields/campaignstep_id/valueProcess.js index 33f528285fb9b97bdc3372e025e1473a2c34d0bd..15e340261a90305d3cb0ddf5925d184e7da805d2 100644 --- a/entity/CampaignParticipant_entity/entityfields/campaignstep_id/valueProcess.js +++ b/entity/CampaignParticipant_entity/entityfields/campaignstep_id/valueProcess.js @@ -3,8 +3,7 @@ import("system.result"); import("system.vars"); if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && - vars.exists("$param.CampaignStepId_param") && - vars.get("$param.CampaignStepId_param")) + vars.exists("$param.CampaignStepId_param") && vars.get("$param.CampaignStepId_param")) { result.string(vars.get("$param.CampaignStepId_param")); } \ No newline at end of file diff --git a/entity/CampaignParticipant_entity/entityfields/contact_id/linkedContextProcess.js b/entity/CampaignParticipant_entity/entityfields/contact_id/linkedContextProcess.js index 8196f20b7e9dcdb56f03f75e7c1f309c3390683e..6e599325755a49424ba25051c71e5367e50c3be9 100644 --- a/entity/CampaignParticipant_entity/entityfields/contact_id/linkedContextProcess.js +++ b/entity/CampaignParticipant_entity/entityfields/contact_id/linkedContextProcess.js @@ -3,5 +3,4 @@ import("system.vars"); import("system.result"); import("Contact_lib"); -logging.log("CONTACT_ID -> getContextByContactId: " +ContactUtils.getContextByContactId(vars.getString("$field.CONTACT_ID"))); result.string(ContactUtils.getContextByContactId(vars.getString("$field.CONTACT_ID"))); \ No newline at end of file diff --git a/entity/CampaignParticipant_entity/entityfields/contactcontext/valueProcess.js b/entity/CampaignParticipant_entity/entityfields/contactcontext/valueProcess.js index 184fa53a959980ca123f3c1040c94571f309ebfb..2e504d63e3b5a3f71b54b072798b3ad09c50984b 100644 --- a/entity/CampaignParticipant_entity/entityfields/contactcontext/valueProcess.js +++ b/entity/CampaignParticipant_entity/entityfields/contactcontext/valueProcess.js @@ -1,9 +1,5 @@ -import("system.logging"); import("system.vars"); import("system.result"); import("Contact_lib"); -logging.log("getContextByContactId: " + ContactUtils.getContextByContactId(vars.getString("$field.CONTACT_ID"))); -logging.log("vars.getString($field.CONTACT_ID: " + vars.getString("$field.CONTACT_ID")); - result.string(ContactUtils.getContextByContactId(vars.getString("$field.CONTACT_ID"))); \ No newline at end of file diff --git a/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/onDBInsert.js b/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/onDBInsert.js new file mode 100644 index 0000000000000000000000000000000000000000..c6903032cc3a3689f688dba12ac13a56c5da533c --- /dev/null +++ b/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/onDBInsert.js @@ -0,0 +1,9 @@ +import("system.vars"); +import("Campaign_lib"); + +var campaignId = vars.get("$field.CAMPAIGN_ID"); +var campaignStepId = vars.get("$field.CAMPAIGNSTEP_ID"); +var contactId = vars.get("$field.CONTACT_ID"); +var campaignParticipantId = vars.get("$field.CAMPAIGNPARTICIPANTID"); + +CampaignUtils.createLogEntry(campaignId, campaignStepId, contactId, campaignParticipantId); \ No newline at end of file diff --git a/entity/CampaignStep_entity/entityfields/campaign_id/valueProcess.js b/entity/CampaignStep_entity/entityfields/campaign_id/valueProcess.js index 7ae7bfcabecdf73776a9fed9fe3cdb09f4485c28..0a46eaaae9f7bf4bc91ccb88e819ea8ce76499e4 100644 --- a/entity/CampaignStep_entity/entityfields/campaign_id/valueProcess.js +++ b/entity/CampaignStep_entity/entityfields/campaign_id/valueProcess.js @@ -2,6 +2,5 @@ import("system.logging"); import("system.result"); import("system.vars"); -logging.log("______CampaignStep_Campaign_ID_valueProcess: -> " + vars.get("$param.campaignId_param")); if(vars.exists("$param.campaignId_param") && vars.get("$param.campaignId_param")) result.string(vars.get("$param.campaignId_param")); \ No newline at end of file diff --git a/process/Campaign_lib/process.js b/process/Campaign_lib/process.js index 739c90141beb7974dd4d7270f97361b243270bb5..c484213432330a580c9ab92b715671ad41a680d6 100644 --- a/process/Campaign_lib/process.js +++ b/process/Campaign_lib/process.js @@ -1,3 +1,4 @@ +import("system.vars"); import("system.db"); import("system.neon"); import("Sql_lib"); @@ -15,11 +16,11 @@ function CampaignUtils() {} /** * Add one Contact (Person or Organistaion) to a Campaign * - * @param {String} pRowId req ContactId + * @param {String} pContactId req ContactId */ -CampaignUtils.addParticipant = function(pRowId) +CampaignUtils.addParticipant = function(pContactId) { - _CampaignUtils._openAddParticipantContext("CampaignParticipant", pRowId, "ContactId_param", "CampaignParticipantEdit_view"); + _CampaignUtils._openAddParticipantContext("CampaignParticipant", pContactId, "ContactId_param", "CampaignParticipantEdit_view"); } /** @@ -70,6 +71,36 @@ CampaignUtils.getCampaignStatusByCampaignId = function(pCampaignId) return KeywordUtils.getViewValue(campaignState, statusId); } +/** + * todo + */ +CampaignUtils.createLogEntry = function(pCampaignId, pCampaignStepId, pContactId, pCampaignParticipantId) +{ + let colsCampaignParticipantLog = CampaignUtils.getParticipantLogInsertColumnNames(); + let colTypesCampaignParticipantLog = CampaignUtils.getParticipantLogInsertColumnTypes(); + + let valsCampaignParticipantLog = new Array(pCampaignId, pCampaignStepId, pContactId, pCampaignParticipantId, vars.get("$sys.user"), vars.get("$sys.date")); + + let rows = db.insertData("CAMPAIGNPARTICIPANTLOG", colsCampaignParticipantLog, colTypesCampaignParticipantLog, valsCampaignParticipantLog); + return (rows == 1); +} + +/** + * todo + */ +CampaignUtils.getParticipantLogInsertColumnNames = function() +{ + return new Array("CAMPAIGN_ID", "CAMPAIGNSTEP_ID", "CONTACT_ID", "CAMPAIGNPARTICIPANTLOGID", "USER_NEW", "DATE_NEW"); +} + +/** + * todo + */ +CampaignUtils.getParticipantLogInsertColumnTypes = function() +{ + return db.getColumnTypes("CAMPAIGNPARTICIPANTLOG", CampaignUtils.getParticipantLogInsertColumnNames()); +} + /** * Methods for campaignmanagement. * Do not create an instance of this! @@ -100,6 +131,9 @@ _CampaignUtils._openAddParticipantContext = function(pContext, pRowIds, pEntityP neon.openContext(pContext, pView, null, neon.OPERATINGSTATE_NEW, params); } +/** + * todo + */ _CampaignUtils._loadSingleValueFromDb = function(pSelectQuery, pConditionField, pConditionValue, pDefaultValue) { let res = pDefaultValue;