From 8bc3f9f05481974606a123bd907bebef3cbc70c2 Mon Sep 17 00:00:00 2001
From: "m.wachsmuth" <m.wachsmuth@MWACHSMUTH.mshome.net>
Date: Wed, 27 Jan 2021 11:46:23 +0100
Subject: [PATCH] =?UTF-8?q?[Projekt:=20Entwicklung=20-=20xRM][TicketNr.:?=
 =?UTF-8?q?=201068586][Firma=20bei=20Kontakt=20readonly,=20wenn=20es=20ber?=
 =?UTF-8?q?eits=20Aktivit=C3=A4ten,=20Eigenschaften,=20etc=20zum=20Kontakt?=
 =?UTF-8?q?=20gibt]?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 entity/Person_entity/Person_entity.aod        |  1 +
 .../organisation_contactid/stateProcess.js    | 23 +++++++++++++++++++
 2 files changed, 24 insertions(+)
 create mode 100644 entity/Person_entity/entityfields/organisation_contactid/stateProcess.js

diff --git a/entity/Person_entity/Person_entity.aod b/entity/Person_entity/Person_entity.aod
index 19c13100a4e..357eefeda69 100644
--- a/entity/Person_entity/Person_entity.aod
+++ b/entity/Person_entity/Person_entity.aod
@@ -913,6 +913,7 @@
       <title>Company</title>
       <consumer>Organisations</consumer>
       <linkedContextProcess>%aditoprj%/entity/Person_entity/entityfields/organisation_contactid/linkedContextProcess.js</linkedContextProcess>
+      <stateProcess>%aditoprj%/entity/Person_entity/entityfields/organisation_contactid/stateProcess.js</stateProcess>
       <valueProcess>%aditoprj%/entity/Person_entity/entityfields/organisation_contactid/valueProcess.js</valueProcess>
       <displayValueProcess>%aditoprj%/entity/Person_entity/entityfields/organisation_contactid/displayValueProcess.js</displayValueProcess>
       <onValidation>%aditoprj%/entity/Person_entity/entityfields/organisation_contactid/onValidation.js</onValidation>
diff --git a/entity/Person_entity/entityfields/organisation_contactid/stateProcess.js b/entity/Person_entity/entityfields/organisation_contactid/stateProcess.js
new file mode 100644
index 00000000000..7d8abdebb5f
--- /dev/null
+++ b/entity/Person_entity/entityfields/organisation_contactid/stateProcess.js
@@ -0,0 +1,23 @@
+import("Context_lib");
+import("system.vars");
+import("system.result");
+import("Entity_lib");
+import("system.neon");
+
+if(vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_EDIT) {
+    
+var currentContext = ContextUtils.getCurrentContextId();
+var contactId = vars.get("$field.CONTACTID");
+    
+var linkedObject = new HasLinkedObjectTester()
+.andNoEntityRows("Activity_entity", "LinkedObjects", {ObjectId_param : currentContext, RowId_param : contactId})
+.andNoEntityRows("360Degree_entity", "PersonObjects", {ObjectRowId_param : contactId , ObjectStatus_param : vars.get("$field.STATUS")})
+.andNoEntityRows("ObjectTree_entity", "TreeProvider", {ObjectIds_param : [vars.get("$field.CONTACTID"), vars.get("$field.PERSON_ID")], ObjectTypes_param : currentContext})
+//.andNoEntityRows("AttributeRelation_entity", "TreeProvider", {ObjectRowId_param : contactId, ObjectType_param : currentContext})
+//.andNoEntityRows("DistrictResponsible_entity", "OrganisationResponsibles", {OrgUid_param : vars.get("$field.ORGANISATION_CONTACTID")}) //District Responsible and Object Tree is default data record
+.andNoEntityRows("Document_entity", "Documents", {AssignmentRowId_param : contactId, AssignmentTable_param : "RELATION"})
+.validate()
+
+if(!linkedObject)
+    result.string(neon.COMPONENTSTATE_READONLY);
+}
\ No newline at end of file
-- 
GitLab