From 474f6226313fbba42e930af8b95dd72b1033dedf Mon Sep 17 00:00:00 2001
From: "a.schindlbeck" <a.schindlbeck@adito.de>
Date: Wed, 3 Jul 2019 15:35:16 +0200
Subject: [PATCH] =?UTF-8?q?AppointmentLinks=20autom.=20l=C3=B6schen=20nach?=
 =?UTF-8?q?=20Appointmentl=C3=B6schung?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../recordcontainers/jdito/onDelete.js               | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/entity/Appointment_entity/recordcontainers/jdito/onDelete.js b/entity/Appointment_entity/recordcontainers/jdito/onDelete.js
index 80fb7869b5f..7abca1e85cd 100644
--- a/entity/Appointment_entity/recordcontainers/jdito/onDelete.js
+++ b/entity/Appointment_entity/recordcontainers/jdito/onDelete.js
@@ -1,6 +1,8 @@
+import("Sql_lib");
 import("system.neon");
 import("system.calendars");
 import("system.vars");
+import("system.db");
 
 
 if (vars.exists("$param.Entry_param"))
@@ -10,4 +12,14 @@ if (vars.exists("$param.Entry_param"))
     if (reccurenceid == undefined) 
         reccurenceid = null;
     calendars.removeEntryByUID(calendars.VEVENT, vars.get("$sys.user"), entry[calendars.ID], reccurenceid)
+    
+    
+    /**
+     * Deletes ApointmentLinks referring to the deleted Appointment.
+     */
+    var cond = SqlCondition.begin();
+    cond.andPrepareValue("AB_APPOINTMENTLINK.APPOINTMENT_ID", entry[calendars.ID])
+    var idscond = db.translateCondition(cond.build("1 = 2"));
+    
+    db.deleteData("AB_APPOINTMENTLINK", idscond);
 }
\ No newline at end of file
-- 
GitLab