From c967c30e14a7fbb2c6867721ff63f81b4d75c7b7 Mon Sep 17 00:00:00 2001
From: "m.wachsmuth" <m.wachsmuth@MWACHSMUTH.mshome.net>
Date: Thu, 28 Jan 2021 12:46:18 +0100
Subject: [PATCH] [Projekt: Entwicklung - xRM][TicketNr.: 1065687][DSGVO
 Meldung nur einmal nach dem Speichern]

---
 entity/Communication_entity/Communication_entity.aod      | 1 +
 entity/Communication_entity/afterOperatingState.js        | 5 +++++
 .../recordcontainers/db/onDBInsert.js                     | 6 +++++-
 .../recordcontainers/db/onDBUpdate.js                     | 8 ++++++--
 4 files changed, 17 insertions(+), 3 deletions(-)
 create mode 100644 entity/Communication_entity/afterOperatingState.js

diff --git a/entity/Communication_entity/Communication_entity.aod b/entity/Communication_entity/Communication_entity.aod
index fa0187084e..6825e5edc5 100644
--- a/entity/Communication_entity/Communication_entity.aod
+++ b/entity/Communication_entity/Communication_entity.aod
@@ -6,6 +6,7 @@
   <majorModelMode>DISTRIBUTED</majorModelMode>
   <documentation>%aditoprj%/entity/Communication_entity/documentation.adoc</documentation>
   <contentTitleProcess>%aditoprj%/entity/Communication_entity/contentTitleProcess.js</contentTitleProcess>
+  <afterOperatingState>%aditoprj%/entity/Communication_entity/afterOperatingState.js</afterOperatingState>
   <recordContainer>db</recordContainer>
   <entityFields>
     <entityField>
diff --git a/entity/Communication_entity/afterOperatingState.js b/entity/Communication_entity/afterOperatingState.js
new file mode 100644
index 0000000000..7085e9f853
--- /dev/null
+++ b/entity/Communication_entity/afterOperatingState.js
@@ -0,0 +1,5 @@
+import("system.vars");
+import("system.neon");
+
+if(vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_VIEW)
+    vars.set("$context.PushDataPrivacyNotification", "false");
\ No newline at end of file
diff --git a/entity/Communication_entity/recordcontainers/db/onDBInsert.js b/entity/Communication_entity/recordcontainers/db/onDBInsert.js
index 5497aac10e..7d836ae39e 100644
--- a/entity/Communication_entity/recordcontainers/db/onDBInsert.js
+++ b/entity/Communication_entity/recordcontainers/db/onDBInsert.js
@@ -11,7 +11,11 @@ var rowdata = vars.get("$local.rowdata");
 var standard = new StandardObject("Communication", vars.get("$local.uid"), "Person", rowdata["COMMUNICATION.CONTACT_ID"])
 standard.onCommunicationInsert(rowdata["COMMUNICATION.MEDIUM_ID"]);
 
-DataPrivacyUtils.notifyNeedDataPrivacyUpdate(rowdata["COMMUNICATION.CONTACT_ID"], vars.get("$param.ShowDsgvoMessage_param"));
+if(vars.exists("$context.PushDataPrivacyNotification") && vars.get("$context.PushDataPrivacyNotification") == "false" && vars.get("$sys.isclient"))
+{
+    DataPrivacyUtils.notifyNeedDataPrivacyUpdate(rowdata["COMMUNICATION.CONTACT_ID"], vars.get("$param.ShowDsgvoMessage_param"));
+    vars.set("$context.PushDataPrivacyNotification", "true");
+} 
 
 if (vars.exists("$param.AdditionalContactIds_param") && vars.get("$param.AdditionalContactIds_param"))
 {
diff --git a/entity/Communication_entity/recordcontainers/db/onDBUpdate.js b/entity/Communication_entity/recordcontainers/db/onDBUpdate.js
index da680f82c2..ebf288114b 100644
--- a/entity/Communication_entity/recordcontainers/db/onDBUpdate.js
+++ b/entity/Communication_entity/recordcontainers/db/onDBUpdate.js
@@ -10,7 +10,11 @@ if (rowdata["COMMUNICATION.CONTACT_ID"] != null)
     var standard = new StandardObject("Communication", vars.get("$local.uid"), "Person", rowdata["COMMUNICATION.CONTACT_ID"])
     standard.onCommunicationUpdate(rowdata["COMMUNICATION.MEDIUM_ID"]);
 }
-  
-DataPrivacyUtils.notifyNeedDataPrivacyUpdate(rowdata["COMMUNICATION.CONTACT_ID"], vars.get("$param.ShowDsgvoMessage_param"));
+
+if(vars.exists("$context.PushDataPrivacyNotification") && vars.get("$context.PushDataPrivacyNotification") == "false" && vars.get("$sys.isclient"))
+{
+    DataPrivacyUtils.notifyNeedDataPrivacyUpdate(rowdata["COMMUNICATION.CONTACT_ID"], vars.get("$param.ShowDsgvoMessage_param"));
+    vars.set("$context.PushDataPrivacyNotification", "true");
+}  
 
 WorkflowSignalSender.updated();
\ No newline at end of file
-- 
GitLab