diff --git a/entity/Salesproject_entity/Salesproject_entity.aod b/entity/Salesproject_entity/Salesproject_entity.aod index b5e35dc2edeed34712c9377bd9a32929d50d3321..d292e27ad9ccd1975040b1498d2f2a35ee4ad63a 100644 --- a/entity/Salesproject_entity/Salesproject_entity.aod +++ b/entity/Salesproject_entity/Salesproject_entity.aod @@ -523,6 +523,7 @@ <conditionProcess>%aditoprj%/entity/Salesproject_entity/recordcontainers/db/conditionProcess.js</conditionProcess> <onDBInsert>%aditoprj%/entity/Salesproject_entity/recordcontainers/db/onDBInsert.js</onDBInsert> <onDBUpdate>%aditoprj%/entity/Salesproject_entity/recordcontainers/db/onDBUpdate.js</onDBUpdate> + <onDBDelete>%aditoprj%/entity/Salesproject_entity/recordcontainers/db/onDBDelete.js</onDBDelete> <linkInformation> <linkInformation> <name>02eb2f4c-3b85-409f-ac13-c8b26804da44</name> diff --git a/entity/Salesproject_entity/recordcontainers/db/onDBDelete.js b/entity/Salesproject_entity/recordcontainers/db/onDBDelete.js new file mode 100644 index 0000000000000000000000000000000000000000..6d045ce9112fca4328a5253e983ff41f722cb449 --- /dev/null +++ b/entity/Salesproject_entity/recordcontainers/db/onDBDelete.js @@ -0,0 +1,27 @@ +import("system.db"); +import("system.logging"); +import("system.vars"); +import("Sql_lib"); + +var currentId = vars.getString("$field.SALESPROJECTID"); + +if (currentId) +{ + var toDelete = [ + "SALESPROJECT_COMPETITION", + "SALESPROJECT_CLASSIFICATION", + "SALESPROJECT_CYCLE", + "SALESPROJECT_FORECAST", + "SALESPROJECT_MEMBER", + "SALESPROJECT_SOURCE" + ]; + + toDelete = toDelete.map(function(pTable) + { + return [pTable, SqlCondition.equals(pTable + ".SALESPROJECT_ID", currentId, "1=2")] + }); + + db.deletes(toDelete); + + // TODO: auch Dokumente, Aktivitäten, Aufgaben, Zeiterfassungen löschen? +} \ No newline at end of file