From b1a9b4206c05d78200ab15326787500c29206278 Mon Sep 17 00:00:00 2001
From: "j.luginger" <j.luginger@adito.de>
Date: Wed, 2 Dec 2020 08:18:39 +0100
Subject: [PATCH] [Projekt: Entwicklung - xRM][TicketNr.:
 1069809][ImporterMappingFunction iAttribute - Attribut wird zu oft angelegt]

---
 process/ImporterMappingFunctions_lib/process.js | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/process/ImporterMappingFunctions_lib/process.js b/process/ImporterMappingFunctions_lib/process.js
index 1598b0c0d1..f85d4a3f1b 100644
--- a/process/ImporterMappingFunctions_lib/process.js
+++ b/process/ImporterMappingFunctions_lib/process.js
@@ -142,7 +142,7 @@ function iAttribute(pObject)
             
             if (i == 0) 
             {
-                var parent = "NULL";
+                var parent = null;
                 // select ab_attributeid from AB_ATTRIBUTE where ATTRIBUTE_NAME = 'Subordinate campaign of' and attribute_parent_id is null
                 id = newSelect(ab_attributeId, alias).from(ab_attribute).where(attribute_name, attributes[i])
                         .and(attribute_parent_id + " is null").cell();
@@ -158,10 +158,18 @@ function iAttribute(pObject)
             {
                 id = util.getNewUUID();
                 if (attributes.length == i+1) type = attributeType;
+                
                 //TODO: add insertNoWait to instantly add AB_ATTRIBUTE records; 
                 //this ensures that nothing is in the funcBuffer that does not exist in the database
                 //TODO: check: are COMOB-values added automatically?
                 var values = [id, parent, attributes[i], type, "1"];
+                
+                if(parent == null)
+                {
+                    values = [id, attributes[i], type, "1"];
+                    columns = [ab_attributeId, attribute_name, attribute_type, attribute_active];
+                }
+                
                 this.insertData(ab_attribute, columns, null, values, alias);
             }   
             pathToFollow["childs"][attributes[i]]["id"] = id;   
-- 
GitLab