From 932aafbb509e0b7480bb3f57b25bf74d83760faa Mon Sep 17 00:00:00 2001
From: Johannes Hoermann <j.hoermann@adito.de>
Date: Thu, 21 Nov 2019 16:09:51 +0100
Subject: [PATCH] Lead import use Sql builder

---
 .../children/contactid_param/valueProcess.js    |  7 ++++---
 .../lead_perscontact/valueProcess.js            | 17 +++++++++--------
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/entity/Lead_entity/entityfields/contactid/children/contactid_param/valueProcess.js b/entity/Lead_entity/entityfields/contactid/children/contactid_param/valueProcess.js
index 2a79f06cc0..5980f8724a 100644
--- a/entity/Lead_entity/entityfields/contactid/children/contactid_param/valueProcess.js
+++ b/entity/Lead_entity/entityfields/contactid/children/contactid_param/valueProcess.js
@@ -3,8 +3,9 @@ import("system.vars");
 import("Sql_lib");
 import("system.db");
 
-var contactId = db.cell(SqlCondition.begin()
-    .andPrepare("CONTACT.PERSON_ID", vars.get("$field.LEAD_PERSON"))
-    .buildSql("select CONTACTID from CONTACT", "1=2"));
+var contactId = newSelect("CONTACTID")
+                    .from("CONTACT")
+                    .whereIfSet("CONTACT.PERSON_ID", "$field.LEAD_PERSON")
+                    .cell(true);
 
 result.string(contactId);
\ No newline at end of file
diff --git a/entity/Lead_entity/entityfields/lead_perscontact/valueProcess.js b/entity/Lead_entity/entityfields/lead_perscontact/valueProcess.js
index 1453e3ed21..50a4a28238 100644
--- a/entity/Lead_entity/entityfields/lead_perscontact/valueProcess.js
+++ b/entity/Lead_entity/entityfields/lead_perscontact/valueProcess.js
@@ -6,13 +6,14 @@ import("system.db");
 var contactId = "";
 
 if(vars.get("$field.LEAD_PERSON"))
-    contactId = db.cell(SqlCondition.begin()
-        .andPrepare("CONTACT.PERSON_ID", vars.get("$field.LEAD_PERSON"))
-        .buildSql("select CONTACTID from CONTACT", "1=2"));
-
+    contactId = newSelect("CONTACTID")
+                    .from("CONTACT")
+                    .whereIfSet("CONTACT.PERSON_ID", "$field.LEAD_PERSON")
+                    .cell(true);
 else
-    contactId = db.cell(SqlCondition.begin()
-        .andPrepare("CONTACT.ORGANISATION_ID", vars.get("$field.LEAD_ORGANISATIONID"))
-        .buildSql("select CONTACTID from CONTACT", "1=2"));
-
+    contactId = newSelect("CONTACTID")
+                    .from("CONTACT")
+                    .whereIfSet("CONTACT.ORGANISATION_ID", "$field.LEAD_ORGANISATIONID")
+                    .cell(true);
+    
 result.string(contactId);
\ No newline at end of file
-- 
GitLab