From 93f9553756d740752db5d12649f3383ec91b9f27 Mon Sep 17 00:00:00 2001
From: "d.buechler" <d.buechler@adito.de>
Date: Fri, 6 Dec 2019 11:23:38 +0100
Subject: [PATCH] If no fields could be found in the pattern (or no pattern
 exists at all) no search for duplicates is excecuted any more in the
 selfDuplicates consumers in Person and Organisation

---
 .../onlyshowcontactids_param/valueProcess.js  | 21 +++++++++++--------
 .../onlyshowcontactids_param/valueProcess.js  | 21 +++++++++++--------
 2 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/entity/Organisation_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js b/entity/Organisation_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js
index 73bdcd3951..f0d2d9c590 100644
--- a/entity/Organisation_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js
+++ b/entity/Organisation_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js
@@ -28,19 +28,22 @@ for (fieldname in entityFieldsToLoad)
     }
 }
 
-let scanResults = DuplicateScannerUtils.ScanForDuplicates(scannerName, targetEntity,
-valuesToCheck, null);
-
 let duplicateIds = [];
 
-if(scanResults != undefined && scanResults != null)
+if(entityFieldsToLoad != null && entityFieldsToLoad.length > 0)
 {
-    //Run thru every duplicate result and read out the id. 
-    //Do it now to have a simple array on all usages lateron.
-    for (let i = 0; i < scanResults.length; i++)
+    let scanResults = DuplicateScannerUtils.ScanForDuplicates(scannerName, targetEntity,
+    valuesToCheck, null);
+
+    if(scanResults != undefined && scanResults != null)
     {
-        let duplicateContactId = scanResults[i][indexsearch.FIELD_ID];
-        duplicateIds.push(duplicateContactId);
+        //Run thru every duplicate result and read out the id.
+        //Do it now to have a simple array on all usages lateron.
+        for (let i = 0; i < scanResults.length; i++)
+        {
+            let duplicateContactId = scanResults[i][indexsearch.FIELD_ID];
+            duplicateIds.push(duplicateContactId);
+        }
     }
 }
 
diff --git a/entity/Person_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js b/entity/Person_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js
index 3a0df6ca06..0546ed77c2 100644
--- a/entity/Person_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js
+++ b/entity/Person_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js
@@ -28,19 +28,22 @@ for (fieldname in entityFieldsToLoad)
     }
 }
 
-let scanResults = DuplicateScannerUtils.ScanForDuplicates(scannerName, targetEntity,
-valuesToCheck, null);
-
 let duplicateIds = [];
 
-if(scanResults != undefined && scanResults != null)
+if(entityFieldsToLoad != null && entityFieldsToLoad.length > 0)
 {
-    //Run thru every duplicate result and read out the id. 
-    //Do it now to have a simple array on all usages lateron.
-    for (let i = 0; i < scanResults.length; i++)
+    let scanResults = DuplicateScannerUtils.ScanForDuplicates(scannerName, targetEntity,
+    valuesToCheck, null);
+
+    if(scanResults != undefined && scanResults != null)
     {
-        let duplicateContactId = scanResults[i][indexsearch.FIELD_ID];
-        duplicateIds.push(duplicateContactId);
+        //Run thru every duplicate result and read out the id.
+        //Do it now to have a simple array on all usages lateron.
+        for (let i = 0; i < scanResults.length; i++)
+        {
+            let duplicateContactId = scanResults[i][indexsearch.FIELD_ID];
+            duplicateIds.push(duplicateContactId);
+        }
     }
 }
 
-- 
GitLab