diff --git a/entity/Campaign_entity/Campaign_entity.aod b/entity/Campaign_entity/Campaign_entity.aod index 1fbad7abc97641cf3ae3ef095620b7d7661c3428..d8d4bc1d15702327cb6ce3295e73dc39e7e5e5e8 100644 --- a/entity/Campaign_entity/Campaign_entity.aod +++ b/entity/Campaign_entity/Campaign_entity.aod @@ -203,6 +203,7 @@ <name>db</name> <alias>Data_alias</alias> <onDBInsert>%aditoprj%/entity/Campaign_entity/recordcontainers/db/onDBInsert.js</onDBInsert> + <onDBDelete>%aditoprj%/entity/Campaign_entity/recordcontainers/db/onDBDelete.js</onDBDelete> <linkInformation> <linkInformation> <name>f3893829-3af2-4e55-ae85-c3a24411a8b8</name> diff --git a/entity/Campaign_entity/recordcontainers/db/onDBDelete.js b/entity/Campaign_entity/recordcontainers/db/onDBDelete.js new file mode 100644 index 0000000000000000000000000000000000000000..fe6d290a0d7833058d4503ef92c6a787bee31f28 --- /dev/null +++ b/entity/Campaign_entity/recordcontainers/db/onDBDelete.js @@ -0,0 +1,22 @@ +import("system.db"); +import("system.vars"); +import("Sql_lib"); + +var currentId = vars.getString("$field.SALESPROJECTID"); + +if (currentId) +{ + var toDelete = [ + "CAMPAIGNCOST", + "CAMPAIGNPARTICIPANT", + "CAMPAIGNPARTICIPANTLOG", + "CAMPAIGNSTEP", + ]; + + toDelete = toDelete.map(function(pTable) + { + return [pTable, SqlCondition.equals(pTable + ".CAMPAIGN_ID", currentId, "1=2")] + }); + + db.deletes(toDelete); +} \ No newline at end of file