From abb71e13b20f568f65e6c9e731e7f7b6c4b179bb Mon Sep 17 00:00:00 2001
From: Sebastian Listl <s.listl@adito.de>
Date: Wed, 30 Sep 2020 16:52:34 +0200
Subject: [PATCH] Faulty activity was created when merging organization
 duplicates

---
 .../integratecurrentintoselectedaction/onActionProcess.js   | 2 +-
 process/DuplicateScanner_lib/process.js                     | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/entity/Organisation_entity/entityfields/duplicateactions/children/integratecurrentintoselectedaction/onActionProcess.js b/entity/Organisation_entity/entityfields/duplicateactions/children/integratecurrentintoselectedaction/onActionProcess.js
index d75b5308bf2..29dab7b72c8 100644
--- a/entity/Organisation_entity/entityfields/duplicateactions/children/integratecurrentintoselectedaction/onActionProcess.js
+++ b/entity/Organisation_entity/entityfields/duplicateactions/children/integratecurrentintoselectedaction/onActionProcess.js
@@ -4,7 +4,7 @@ import("system.neon");
 import("DuplicateScanner_lib");
 
 let sourceContactId = vars.get("$param.DuplicateCurrentContactId_param");
-let targetContactId = vars.get("$sys.selection");
+let targetContactId = vars.get("$sys.selection")[0];
 
 //todo the actual merge ought to happen in a separate view where the contact infos can be merged manually by the user.
 let mergeSuccess = DuplicateScannerUtils.mergeOrganisation(sourceContactId, targetContactId);
diff --git a/process/DuplicateScanner_lib/process.js b/process/DuplicateScanner_lib/process.js
index e85d22cd516..d6feb5a5ebb 100644
--- a/process/DuplicateScanner_lib/process.js
+++ b/process/DuplicateScanner_lib/process.js
@@ -673,8 +673,8 @@ DuplicateScannerUtils.mergeOrganisation = function(pSourceContactId, pTargetCont
         .where("CONTACT.CONTACTID", pSourceContactId)
         .cell();
         
-    var isLinkedDataUpdated = _DuplicateScannerUtils._migrateLinkedContactData(pSourceContactId, pTargetContactId);
-    var isParticipantsUpdated = _DuplicateScannerUtils._migrateParticipantsToNewContact("CAMPAIGNPARTICIPANT", "CONTACT_ID", "CAMPAIGN_ID", 
+    _DuplicateScannerUtils._migrateLinkedContactData(pSourceContactId, pTargetContactId);
+    _DuplicateScannerUtils._migrateParticipantsToNewContact("CAMPAIGNPARTICIPANT", "CONTACT_ID", "CAMPAIGN_ID", 
         pSourceContactId, pTargetContactId);
     
     var deleteStatements = [];
@@ -692,7 +692,7 @@ DuplicateScannerUtils.mergeOrganisation = function(pSourceContactId, pTargetCont
 
     DuplicateScannerUtils.deleteCachedDuplicate(pSourceContactId);
 
-    return ((isLinkedDataUpdated || isParticipantsUpdated) && deletedRows >= 2);
+    return deletedRows >= 2;
 }
 
 /*
-- 
GitLab