From af3c2a421e6ce033a8f80b756ee3b1ca96473c55 Mon Sep 17 00:00:00 2001
From: "j.goderbauer" <j.goderbauer@adito.de>
Date: Wed, 9 Sep 2020 09:33:57 +0200
Subject: [PATCH] AroundLocation fix: did not update when radius was removed

---
 .../entityfields/contactids/valueProcess.js            | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/entity/AroundLocation_entity/entityfields/contactids/valueProcess.js b/entity/AroundLocation_entity/entityfields/contactids/valueProcess.js
index 8c557caa9b..c501306c78 100644
--- a/entity/AroundLocation_entity/entityfields/contactids/valueProcess.js
+++ b/entity/AroundLocation_entity/entityfields/contactids/valueProcess.js
@@ -5,12 +5,14 @@ import("system.indexsearch");
 import("system.neon");
 
 var contactIds = [];
+var hitCount = 0;
+var totalHitCount = 0;
 
 var radius = vars.get("$field.SearchRadius");
 var lat  = vars.get("$param.LocationLat_param");
 var lon  = vars.get("$param.LocationLon_param");
 
-if (radius && lat && lon)
+if (radius && lat && lon && !vars.get("$sys.validationerrors"))
 {
     //filter our origin uid because otherwise we would have the origin organisation in our resultset
     var excludedUid = vars.get("$param.OriginUid_param");
@@ -50,8 +52,10 @@ if (radius && lat && lon)
         contactIds = indexResult.HITS.map(function (e){
             return e[indexsearch.FIELD_ID];
         });
-        neon.setFieldValue("$field.HitCount", contactIds.length);
-        neon.setFieldValue("$field.TotalHitCount", indexResult.TOTALHITS);
+    hitCount = contactIds.length;
+    totalHitCount = indexResult.TOTALHITS;
 }
 
+neon.setFieldValue("$field.HitCount", hitCount);
+neon.setFieldValue("$field.TotalHitCount", totalHitCount);
 result.string(JSON.stringify(contactIds));
\ No newline at end of file
-- 
GitLab