diff --git a/entity/AttributeRelation_entity/entityfields/valueproxy/possibleItemsProcess.js b/entity/AttributeRelation_entity/entityfields/valueproxy/possibleItemsProcess.js
index 48d4fad4ddf725f12175066ac343037d6f22a320..4a7f1e46eda7a88afbfe7523691dd836a6f774bf 100644
--- a/entity/AttributeRelation_entity/entityfields/valueproxy/possibleItemsProcess.js
+++ b/entity/AttributeRelation_entity/entityfields/valueproxy/possibleItemsProcess.js
@@ -14,7 +14,7 @@ if (attrType == $AttributeTypes.COMBO)
         .andPrepare("AB_ATTRIBUTE.ATTRIBUTE_ACTIVE", "1")
         .andPrepare("AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID", attributeId)
         .andPrepare("AB_ATTRIBUTE.ATTRIBUTE_TYPE", $AttributeTypes.COMBOVALUE)
-        .buildSql("select AB_ATTRIBUTEID, ATTRIBUTE_NAME from AB_ATTRIBUTE");
+        .buildSql("select AB_ATTRIBUTEID, ATTRIBUTE_NAME from AB_ATTRIBUTE", "1=2", "order by ATTRIBUTE_NAME");
     var valueList = db.table(valueSql);
     result.object(valueList);
 }
diff --git a/entity/Attribute_entity/Attribute_entity.aod b/entity/Attribute_entity/Attribute_entity.aod
index ead7f6425a4604beef2597cfa3a3688a20292c1b..a658dcc50f76b820690dbc2a10ae351816a92225 100644
--- a/entity/Attribute_entity/Attribute_entity.aod
+++ b/entity/Attribute_entity/Attribute_entity.aod
@@ -36,12 +36,17 @@
     <entityField>
       <name>ATTRIBUTE_PARENT_ID</name>
       <title>Superordinate Attribute</title>
-      <consumer>AttributeChildren</consumer>
+      <consumer>AttributeGroup</consumer>
       <linkedContext>Attribute</linkedContext>
       <searchable v="false" />
       <stateProcess>%aditoprj%/entity/Attribute_entity/entityfields/attribute_parent_id/stateProcess.js</stateProcess>
       <valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/attribute_parent_id/valueProcess.js</valueProcess>
       <displayValueProcess>%aditoprj%/entity/Attribute_entity/entityfields/attribute_parent_id/displayValueProcess.js</displayValueProcess>
+      <onValueChange>%aditoprj%/entity/Attribute_entity/entityfields/attribute_parent_id/onValueChange.js</onValueChange>
+      <onValueChangeTypes>
+        <element>MASK</element>
+        <element>PROCESS</element>
+      </onValueChangeTypes>
     </entityField>
     <entityConsumer>
       <name>AttributeChildren</name>
@@ -90,8 +95,6 @@
         </entityParameter>
         <entityParameter>
           <name>GetGroups_param</name>
-          <valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/attributeparent/children/getgroups_param/valueProcess.js</valueProcess>
-          <expose v="true" />
         </entityParameter>
       </children>
     </entityProvider>
@@ -243,6 +246,37 @@
       <title>Name</title>
       <valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/name_with_type/valueProcess.js</valueProcess>
     </entityField>
+    <entityProvider>
+      <name>AttributeGroups</name>
+      <fieldType>DEPENDENCY_IN</fieldType>
+      <recordContainer>db</recordContainer>
+      <children>
+        <entityParameter>
+          <name>GetGroups_param</name>
+          <valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/attributegroups/children/getgroups_param/valueProcess.js</valueProcess>
+          <expose v="true" />
+        </entityParameter>
+        <entityParameter>
+          <name>AttrParentId_param</name>
+          <expose v="true" />
+        </entityParameter>
+      </children>
+    </entityProvider>
+    <entityConsumer>
+      <name>AttributeGroup</name>
+      <fieldType>DEPENDENCY_OUT</fieldType>
+      <dependency>
+        <name>dependency</name>
+        <entityName>Attribute_entity</entityName>
+        <fieldName>AttributeGroups</fieldName>
+      </dependency>
+      <children>
+        <entityParameter>
+          <name>AttrParentId_param</name>
+          <valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/attributegroup/children/attrparentid_param/valueProcess.js</valueProcess>
+        </entityParameter>
+      </children>
+    </entityConsumer>
   </entityFields>
   <recordContainers>
     <dbRecordContainer>
diff --git a/entity/Attribute_entity/entityfields/attribute_parent_id/onValueChange.js b/entity/Attribute_entity/entityfields/attribute_parent_id/onValueChange.js
new file mode 100644
index 0000000000000000000000000000000000000000..06db0b11a5c5b5148b3dced909c236bb63f01e9a
--- /dev/null
+++ b/entity/Attribute_entity/entityfields/attribute_parent_id/onValueChange.js
@@ -0,0 +1,38 @@
+import("system.db");
+import("system.neon");
+import("system.vars");
+import("Attribute_lib");
+
+if (vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_EDIT)
+{
+    var level = 0;
+    if (vars.get("$field.ATTRIBUTE_PARENT_ID") != "")
+    {
+        level = db.cell(SqlCondition.begin()
+            .andPrepare("AB_ATTRIBUTE.AB_ATTRIBUTEID", vars.get("$field.ATTRIBUTE_PARENT_ID"))
+            .buildSql("select ATTRIBUTE_LEVEL from AB_ATTRIBUTE"));
+        level = parseInt(level) + 1;
+    }
+    neon.setFieldValue("$field.ATTRIBUTE_LEVEL", level);
+    
+    var table = "AB_ATTRIBUTE";
+    var columns = ["ATTRIBUTE_LEVEL"];
+    var types = db.getColumnTypes(table, columns);
+    var toUpdate = [];
+    
+    var attributes = [vars.get("$field.AB_ATTRIBUTEID")];
+    while (attributes.length > 0)
+    {
+        var condition = SqlCondition.begin()
+            .and("AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID in ('" + attributes.join("','") + "')");
+            
+        toUpdate.push([table, columns, types, [String(++level)], condition.build()]);
+            
+        attributes = db.array(db.COLUMN, SqlCondition.begin()
+            .and("AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID in ('" + attributes.join("','") + "')")
+            .buildSql("select AB_ATTRIBUTEID from AB_ATTRIBUTE")
+        );
+    }
+    
+    db.updates(toUpdate);
+}
\ No newline at end of file
diff --git a/entity/Attribute_entity/entityfields/attribute_parent_id/stateProcess.js b/entity/Attribute_entity/entityfields/attribute_parent_id/stateProcess.js
index 11f1cb994026398ca6df3cfcffd3157ed05f78f7..cac55643fb4daad7e6ccb3511aab9c1410182b77 100644
--- a/entity/Attribute_entity/entityfields/attribute_parent_id/stateProcess.js
+++ b/entity/Attribute_entity/entityfields/attribute_parent_id/stateProcess.js
@@ -1,11 +1,12 @@
 import("system.result");
 import("system.neon");
 import("system.vars");
+import("Attribute_lib");
 
 var fieldState;
-if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
-    fieldState = neon.COMPONENTSTATE_AUTO;
-else
+if(vars.get("$field.ATTRIBUTE_TYPE").trim() == $AttributeTypes.COMBOVALUE)
     fieldState = neon.COMPONENTSTATE_READONLY;
+else
+    fieldState = neon.COMPONENTSTATE_AUTO;
 
 result.string(fieldState);
\ No newline at end of file
diff --git a/entity/Attribute_entity/entityfields/attributegroup/children/attrparentid_param/valueProcess.js b/entity/Attribute_entity/entityfields/attributegroup/children/attrparentid_param/valueProcess.js
new file mode 100644
index 0000000000000000000000000000000000000000..033bf9a666c5254c8945077776b2834560164e56
--- /dev/null
+++ b/entity/Attribute_entity/entityfields/attributegroup/children/attrparentid_param/valueProcess.js
@@ -0,0 +1,4 @@
+import("system.vars");
+import("system.result");
+
+result.string(vars.get("$field.AB_ATTRIBUTEID"));
\ No newline at end of file
diff --git a/entity/Attribute_entity/entityfields/attributegroups/children/getgroups_param/valueProcess.js b/entity/Attribute_entity/entityfields/attributegroups/children/getgroups_param/valueProcess.js
new file mode 100644
index 0000000000000000000000000000000000000000..28d4124c73ca29db763c77486a84b9362ec6d7aa
--- /dev/null
+++ b/entity/Attribute_entity/entityfields/attributegroups/children/getgroups_param/valueProcess.js
@@ -0,0 +1,3 @@
+import("system.result");
+
+result.string(true);
\ No newline at end of file
diff --git a/entity/Attribute_entity/entityfields/attributeparent/children/getgroups_param/valueProcess.js b/entity/Attribute_entity/entityfields/attributeparent/children/getgroups_param/valueProcess.js
deleted file mode 100644
index 289c6a9357f3e98c026acb10dab34501ad5daea5..0000000000000000000000000000000000000000
--- a/entity/Attribute_entity/entityfields/attributeparent/children/getgroups_param/valueProcess.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import("system.neon");
-import("system.vars");
-import("system.result");
-
-result.string(vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_NEW || "");
\ No newline at end of file
diff --git a/entity/Attribute_entity/recordcontainers/db/conditionProcess.js b/entity/Attribute_entity/recordcontainers/db/conditionProcess.js
index 1a3010539738aaddde2f405ac7369f7c4bfffe08..ed323a5c82da868f9b3ae4deafd54ad035520109 100644
--- a/entity/Attribute_entity/recordcontainers/db/conditionProcess.js
+++ b/entity/Attribute_entity/recordcontainers/db/conditionProcess.js
@@ -10,8 +10,12 @@ var getGroups = vars.exists("$param.GetGroups_param") && vars.get("$param.GetGro
 var objectType = vars.exists("$param.ObjectType_param") && vars.get("$param.ObjectType_param");
 if (getGroups)
 {
+    //this is for the selection of the superordinate attribute, this condition
+    //filters out the own id and the children to prevent loops
     condition = db.translateCondition(SqlCondition.begin()
         .andPrepare("AB_ATTRIBUTE.ATTRIBUTE_TYPE", $AttributeTypes.GROUP)
+        .andPrepareVars("AB_ATTRIBUTE.AB_ATTRIBUTEID", "$param.AttrParentId_param", "# != ?")
+        .and("AB_ATTRIBUTE.AB_ATTRIBUTEID not in ('" + AttributeUtil.getAllChildren(vars.getString("$param.AttrParentId_param")).join("','") + "')")
         .build());
 }
 else if (objectType)  //if there's an objectType, it comes from the AttributeRelation entity
diff --git a/entity/Attribute_entity/recordcontainers/db/orderClauseProcess.js b/entity/Attribute_entity/recordcontainers/db/orderClauseProcess.js
index 4b14378884f0ed11d22218c0e63a66614d3d1d90..003688a8bb9231d8f68eada88a41012db8d2ac2c 100644
--- a/entity/Attribute_entity/recordcontainers/db/orderClauseProcess.js
+++ b/entity/Attribute_entity/recordcontainers/db/orderClauseProcess.js
@@ -1,3 +1,6 @@
 import("system.db");
 import("system.result");
-result.object({"AB_ATTRIBUTE.ATTRIBUTE_LEVEL" : db.ASCENDING});
\ No newline at end of file
+result.object({
+    "AB_ATTRIBUTE.ATTRIBUTE_LEVEL" : db.ASCENDING,
+    "AB_ATTRIBUTE.ATTRIBUTE_NAME" : db.ASCENDING
+});
\ No newline at end of file