From b8c287383deb33ff23ca64967805f48f4d4daeb6 Mon Sep 17 00:00:00 2001
From: Sebastian Listl <s.listl@adito.de>
Date: Tue, 1 Sep 2020 10:43:53 +0200
Subject: [PATCH] #1064546 indexsearch did not work with Organisation and
 Person

---
 entity/Organisation_entity/Organisation_entity.aod     | 10 ----------
 .../recordcontainers/index/query.js                    |  6 ++----
 entity/Person_entity/recordcontainers/index/query.js   |  9 ++-------
 3 files changed, 4 insertions(+), 21 deletions(-)

diff --git a/entity/Organisation_entity/Organisation_entity.aod b/entity/Organisation_entity/Organisation_entity.aod
index d4baac32bb..8ae5e1fe3a 100644
--- a/entity/Organisation_entity/Organisation_entity.aod
+++ b/entity/Organisation_entity/Organisation_entity.aod
@@ -1357,16 +1357,6 @@
       </affectedTables>
       <affectedIds>%aditoprj%/entity/Organisation_entity/recordcontainers/index/affectedIds.js</affectedIds>
       <indexFieldMappings>
-        <indexRecordFieldMapping>
-          <name>#LOCATION</name>
-          <indexFieldType>LOCATION</indexFieldType>
-          <additionalFieldNameAliases>
-            <element>location</element>
-          </additionalFieldNameAliases>
-          <isGlobalSearchField v="false" />
-          <isFilterable v="false" />
-          <isLookupFilter v="false" />
-        </indexRecordFieldMapping>
         <indexRecordFieldMapping>
           <name>NAME.value</name>
           <indexFieldType>PROPER_NAME</indexFieldType>
diff --git a/entity/Organisation_entity/recordcontainers/index/query.js b/entity/Organisation_entity/recordcontainers/index/query.js
index 10ff797d42..075671c143 100644
--- a/entity/Organisation_entity/recordcontainers/index/query.js
+++ b/entity/Organisation_entity/recordcontainers/index/query.js
@@ -46,9 +46,7 @@ var querySelect = newSelect("CONTACT.CONTACTID "
                     .leftJoin("COMMUNICATION", "PHONE.CONTACT_ID = CONTACT.CONTACTID and PHONE.MEDIUM_ID in ('" + CommMediumPhoneIds.join("', '") + "')", "PHONE")//TODO: refactor to new SqlBuilder
                     .where("CONTACT.STATUS", $KeywordRegistry.contactStatus$inactive(), SqlBuilder.NOT_EQUAL())
 
-if (vars.exists("$local.idvalue") && vars.get("$local.idvalue") && vars.get("$local.idvalue").length > 0) 
-{
-    querySelect.where("CONTACT.CONTACTID", vars.get("$local.idvalue"), SqlBuilder.IN());
-}
+if (vars.exists("$local.idvalue"))
+    querySelect.whereIfSet("CONTACT.CONTACTID", "$local.idvalue");
 
 result.string(querySelect.toString());
diff --git a/entity/Person_entity/recordcontainers/index/query.js b/entity/Person_entity/recordcontainers/index/query.js
index efe2af2c2e..e72a0822ec 100644
--- a/entity/Person_entity/recordcontainers/index/query.js
+++ b/entity/Person_entity/recordcontainers/index/query.js
@@ -42,7 +42,6 @@ var querySelect = newSelect("CONTACT.CONTACTID "
                         )
                     .from("PERSON")
                     .join("CONTACT", "CONTACT.PERSON_ID = PERSON.PERSONID")
-                    .and("CONTACT.STATUS", $KeywordRegistry.contactStatus$inactive(), SqlBuilder.NOT_EQUAL())
                     .join("ORGANISATION", "CONTACT.ORGANISATION_ID = ORGANISATION.ORGANISATIONID")
                     .leftJoin("ADDRESS", "defaultAddress.ADDRESSID = CONTACT.ADDRESS_ID", "defaultAddress")
                     .leftJoin("ADDRESS", "ADDRESS.CONTACT_ID = CONTACT.CONTACTID")
@@ -51,11 +50,7 @@ var querySelect = newSelect("CONTACT.CONTACTID "
                     .where("CONTACT.STATUS", $KeywordRegistry.contactStatus$inactive(), SqlBuilder.NOT_EQUAL())
                     .orderBy("CONTACT.CONTACTID");
 
-if (vars.exists("$local.idvalue")) 
-{
-    affectedIds = vars.get("$local.idvalue");
-    querySelect.whereIfSet("CONTACT.CONTACTID", affectedIds, SqlBuilder.IN());
-}
-
+if (vars.exists("$local.idvalue"))
+    querySelect.whereIfSet("CONTACT.CONTACTID", "$local.idvalue");
 
 result.string(querySelect);
\ No newline at end of file
-- 
GitLab