From 632d672bf9ef21dc49298c749484b00b60ce2d32 Mon Sep 17 00:00:00 2001
From: "f.maier" <f.maier@adito.de>
Date: Wed, 20 Oct 2021 15:28:53 +0200
Subject: [PATCH] --Remove Loggings [Projekt: xRM-ContactManagement][TicketNr.:
 2001586][EWS-Global User Variable funktioniert nicht]

---
 .../CampaignPlanning_entity.aod                    |  5 -----
 .../children/testfilter/onActionProcess.js         |  3 ---
 entity/Person_entity/Person_entity.aod             |  2 --
 .../children/addsyncentry/onActionProcess.js       |  4 ++--
 .../recordcontainers/db/conditionProcess.js        |  1 -
 .../recordcontainers/db/onDBInsert.js              |  2 --
 process/EwsSyncContact_lib/process.js              |  5 +++++
 process/EwsSyncContact_serverProcess/process.js    | 14 ++++++++------
 8 files changed, 15 insertions(+), 21 deletions(-)
 delete mode 100644 entity/CampaignPlanning_entity/entityfields/newganttentries/children/testfilter/onActionProcess.js

diff --git a/entity/CampaignPlanning_entity/CampaignPlanning_entity.aod b/entity/CampaignPlanning_entity/CampaignPlanning_entity.aod
index 7d1b72b5fd..536bd367d1 100644
--- a/entity/CampaignPlanning_entity/CampaignPlanning_entity.aod
+++ b/entity/CampaignPlanning_entity/CampaignPlanning_entity.aod
@@ -64,11 +64,6 @@
           <iconId>NEON:GROUP_APPOINTMENT</iconId>
           <tooltipProcess>%aditoprj%/entity/CampaignPlanning_entity/entityfields/newganttentries/children/createnewcampaignstep_action/tooltipProcess.js</tooltipProcess>
         </entityActionField>
-        <entityActionField>
-          <name>testfilter</name>
-          <title>testfilter</title>
-          <onActionProcess>%aditoprj%/entity/CampaignPlanning_entity/entityfields/newganttentries/children/testfilter/onActionProcess.js</onActionProcess>
-        </entityActionField>
       </children>
     </entityActionGroup>
     <entityField>
diff --git a/entity/CampaignPlanning_entity/entityfields/newganttentries/children/testfilter/onActionProcess.js b/entity/CampaignPlanning_entity/entityfields/newganttentries/children/testfilter/onActionProcess.js
deleted file mode 100644
index 0179cd4c1c..0000000000
--- a/entity/CampaignPlanning_entity/entityfields/newganttentries/children/testfilter/onActionProcess.js
+++ /dev/null
@@ -1,3 +0,0 @@
-import("system.vars");
-import("system.logging");
-logging.log(JSON.stringify(vars.get("$sys.filter")));
\ No newline at end of file
diff --git a/entity/Person_entity/Person_entity.aod b/entity/Person_entity/Person_entity.aod
index 369578612a..a21215e601 100644
--- a/entity/Person_entity/Person_entity.aod
+++ b/entity/Person_entity/Person_entity.aod
@@ -1524,8 +1524,6 @@
         <dbRecordFieldMapping>
           <name>ORGANISATION_NAME.value</name>
           <recordfield>ORGANISATION.NAME</recordfield>
-          <isFilterable v="true" />
-          <isLookupFilter v="true" />
         </dbRecordFieldMapping>
         <dbRecordFieldMapping>
           <name>USER_NEW.value</name>
diff --git a/entity/SearchSync_entity/entityfields/syncentrygroup/children/addsyncentry/onActionProcess.js b/entity/SearchSync_entity/entityfields/syncentrygroup/children/addsyncentry/onActionProcess.js
index 315554deca..ec26f78f70 100644
--- a/entity/SearchSync_entity/entityfields/syncentrygroup/children/addsyncentry/onActionProcess.js
+++ b/entity/SearchSync_entity/entityfields/syncentrygroup/children/addsyncentry/onActionProcess.js
@@ -50,7 +50,7 @@ asysUsersData.forEach(function ([groupId, name, id, propvalClob])
         .leftJoin("ADDRESS", "ADDRESS.ADDRESSID = CONTACT.ADDRESS_ID"); 
     }
     //from organisation or from person   
-                
+            
     if(whereCond)
     {
         sqlSyncSizeString.where(whereCond);
@@ -61,7 +61,7 @@ asysUsersData.forEach(function ([groupId, name, id, propvalClob])
     if(syncsize > maxSyncsize)
     {                 
         db.updateData("ASYS_USERS", ["PROPVAL_CLOB"], null, 
-            ["Search greater %0, sync. not possible"], newWhere("ASYS_USERS.ID", syncId), SqlUtils.getBinariesAlias());
+            ["Search greater %0, sync. not possible"], newWhere("ASYS_USERS.ID", syncId).toString(), SqlUtils.getBinariesAlias());
     }
 });
 
diff --git a/entity/SearchSync_entity/recordcontainers/db/conditionProcess.js b/entity/SearchSync_entity/recordcontainers/db/conditionProcess.js
index 9e28fc745a..acd0e634e7 100644
--- a/entity/SearchSync_entity/recordcontainers/db/conditionProcess.js
+++ b/entity/SearchSync_entity/recordcontainers/db/conditionProcess.js
@@ -10,5 +10,4 @@ var cond = newWhereIfSet("ASYS_USERS.NAME", userId)
             .and(newWhereIfSet("ASYS_USERS.PROPKEY", "#FILTER:Organisation_entity.SAVED:%", SqlBuilder.LIKE())
             .or("ASYS_USERS.PROPKEY", "#FILTER:Person_entity.SAVED:%", SqlBuilder.LIKE()))
             .and(newWhereIfSet("ASYS_USERS.PROPKEY != 'SearchSync'"));
-logging.log(cond.toString());
 result.string(cond.toString());
diff --git a/entity/SerialLetter_entity/recordcontainers/db/onDBInsert.js b/entity/SerialLetter_entity/recordcontainers/db/onDBInsert.js
index 683f7df026..b8e70bd3b9 100644
--- a/entity/SerialLetter_entity/recordcontainers/db/onDBInsert.js
+++ b/entity/SerialLetter_entity/recordcontainers/db/onDBInsert.js
@@ -1,4 +1,3 @@
-import("system.logging");
 import("Workflow_lib");
 import("Binary_lib");
 import("Sql_lib");
@@ -16,7 +15,6 @@ var template = DocumentTemplate.fromUpload(bindata);
 
 if (template.content)
 {
-    logging.log("inside");
     SingleBinaryUtils.insert("SERIALLETTER", "SERIALLETTERFILE", letterId, template.content, template.filename, "", "SERIALLETTER_BUILDED");
 }
 
diff --git a/process/EwsSyncContact_lib/process.js b/process/EwsSyncContact_lib/process.js
index 3e42ff4620..123a053a22 100644
--- a/process/EwsSyncContact_lib/process.js
+++ b/process/EwsSyncContact_lib/process.js
@@ -687,6 +687,11 @@ EwsClientSyncUtils.updateEntrysInSyncTable = function(pUserMapping, pUserLoginPr
                     var search = JSON.parse(pPropvalClob)["search"]; // search part of the filter JSON
                     var whereCond = db.toFilterCondition(JSON.stringify(search), type);
                     //--------------------------------------------------------------------------
+                    if(whereCond)//global variables cannot be read here and must be passed per user
+                    {
+                        whereCond = StringUtils.replaceAll(whereCond, "$$$global.user.contactId$$$", tempUserMapping[2]);
+                    }
+                    
                     var sqlString = new SqlBuilder().selectDistinct("CONTACT.CONTACTID")
                     .from("CONTACT")
                     .whereIfSet(whereCond);
diff --git a/process/EwsSyncContact_serverProcess/process.js b/process/EwsSyncContact_serverProcess/process.js
index 44c61861a6..a319401891 100644
--- a/process/EwsSyncContact_serverProcess/process.js
+++ b/process/EwsSyncContact_serverProcess/process.js
@@ -7,22 +7,24 @@ import("system.db");
 var maskingUtils = new SqlMaskingUtils();
 
 //get all active usertitles and usernames
-var userLoginPropval = newSelect(["ASYS_USERS.PROPVAL", "ASYS_USERS.NAME"], SqlUtils.getSystemAlias())
+var userLoginPropval = newSelect(["ASYS_USERS.PROPVAL", "ASYS_USERS.NAME", "userContactId.PROPVAL"], SqlUtils.getSystemAlias())
 .from("ASYS_USERS")
-.join("ASYS_USERS", "innerUser.NAME = ASYS_USERS.NAME", "innerUser")
-.where(["ASYS_USERS", "PROPVAL", "innerUser"], "true")
-.and(["ASYS_USERS", "PROPKEY", "innerUser"], "isActive")
+.join("ASYS_USERS", "userName.NAME = ASYS_USERS.NAME", "userName")
+.join("ASYS_USERS", "userContactId.NAME = ASYS_USERS.NAME", "userContactId")
+.where(["ASYS_USERS", "PROPVAL", "userName"], "true")
+.and(["ASYS_USERS", "PROPKEY", "userName"], "isActive")
+.and(["ASYS_USERS", "PROPKEY", "userContactId"], "contactID")
 .and("ASYS_USERS.PROPKEY", "title")
 .table();
 
 var userMapping = [];
 var storedSearchMapping = [];
 
-userLoginPropval.forEach(function([pPropval, pName]) 
+userLoginPropval.forEach(function([pPropval, pName, pContactId]) 
 {
     if(userMapping[pName] == undefined)
     {
-        userMapping[pName] = [pPropval, pName];//userLoginPropval[NAME] = PROPVAL, NAME
+        userMapping[pName] = [pPropval, pName, pContactId];//userLoginPropval[NAME] = PROPVAL, NAME, CONTACTID
     }
 });//mapping
 
-- 
GitLab