From da7ff9f745edd306f36a5fadf91eb0d7b172cd2c Mon Sep 17 00:00:00 2001
From: Sebastian Pongratz <s.pongratz@adito.de>
Date: Tue, 30 Nov 2021 10:39:26 +0100
Subject: [PATCH] [Projekt: xRM-ContactManagement][TicketNr.:
 2002042][Fehlerhafter...

---
 process/Leadimport_lib/process.js |  2 +-
 process/Loghistory_lib/process.js | 11 +++++++----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/process/Leadimport_lib/process.js b/process/Leadimport_lib/process.js
index f92149a937..38cf8c564a 100644
--- a/process/Leadimport_lib/process.js
+++ b/process/Leadimport_lib/process.js
@@ -936,7 +936,7 @@ LeadImportUtils.scanLeadDups = function(pAllContactData)
        
         updDupVals = [dupStatus];
     
-        toUpdate.push([dupUpdateLeadTable, ["DUPSTATUS"], null, updDupVals, newWhere([dupUpdateLeadTable, "LEADID"], leadID).build()]);
+        toUpdate.push([dupUpdateLeadTable, ["DUPSTATUS"], null, updDupVals, newWhere([dupUpdateLeadTable, "LEADSID"], leadID).build()]);
     }
     db.updates(toUpdate);//update Leads with the new status
 }
diff --git a/process/Loghistory_lib/process.js b/process/Loghistory_lib/process.js
index 03c42abab2..99a4e42755 100644
--- a/process/Loghistory_lib/process.js
+++ b/process/Loghistory_lib/process.js
@@ -541,7 +541,7 @@ AuditUpdateSyncEntries.prototype.execute = function()
     switch (this.sqlAction + "-" + this.table) 
     { 
         case "U-CONTACT":
-            subSQL = this.idValue;
+            subSQL = [this.idValue];
             break;
         case "U-PERSON":
             subSQL = newSelect("CONTACT.CONTACTID").from("CONTACT").where("CONTACT.PERSON_ID", this.idValue);
@@ -555,7 +555,7 @@ AuditUpdateSyncEntries.prototype.execute = function()
             check = subSQL.arrayColumn().length > 0;
             break;
         case "D-ADDRESS":
-            subSQL = this.oldValues[this.columns.indexOf("CONTACT_ID")];
+            subSQL = [this.oldValues[this.columns.indexOf("CONTACT_ID")]];
             break;
         case "I-COMMUNICATION":
         case "U-COMMUNICATION":
@@ -563,11 +563,14 @@ AuditUpdateSyncEntries.prototype.execute = function()
             check = subSQL.arrayColumn().length > 0;
             break;
         case "D-COMMUNICATION":
-            subSQL = this.oldValues[this.columns.indexOf("CONTACT_ID")];
+            subSQL = [this.oldValues[this.columns.indexOf("CONTACT_ID")]];
+            break;
+        default:
+            check = false;
             break;
     } 
 
-    if(check)
+    if(check && !Utils.isNullOrEmpty(subSQL))
     {  
         newWhere("AB_SYNCCONTACT.CONTACT_ID", subSQL, SqlBuilder.IN())
         .updateData(true, "AB_SYNCCONTACT", ["DATE_EDIT", "UPDATECONTACT"] , null, [vars.getString("$sys.date"), '1'], datetime.ONE_MINUTE * 5);
-- 
GitLab