diff --git a/entity/RoleChildren_entity/entityfields/child_role/dropDownProcess.js b/entity/RoleChildren_entity/entityfields/child_role/dropDownProcess.js index 9d8e51b74c8bca7e6cb18db08e92a7179735fa3f..34affa61dc9eb6de36676e40f39582359f29b54c 100644 --- a/entity/RoleChildren_entity/entityfields/child_role/dropDownProcess.js +++ b/entity/RoleChildren_entity/entityfields/child_role/dropDownProcess.js @@ -1,15 +1,21 @@ +import("Sql_lib"); import("system.tools"); import("system.vars"); import("system.result"); -var childRoles = []; +var newChildRoles = []; +var alias = SqlUtils.getSystemAlias(); var parentRole = vars.get("$param.RoleId_param"); var allCustomAndProjectRoles = tools.getAllRoles(["CUSTOM", "PROJECT"], true); +var childRoles = newSelect("CHILD_ROLE", alias) +.from("ASYS_ROLES_CHILDREN") +.where("ASYS_ROLES_CHILDREN.PARENT_ROLE", parentRole) +.table(); for each (let role in allCustomAndProjectRoles) { - if (role[3] != parentRole) { - childRoles.push([role[3], role[3]]); + if (role[3] != parentRole) { // dont show same role as parent in dropdown + newChildRoles.push([role[3], role[3]]); } } -result.object(childRoles.sort()); \ No newline at end of file +result.object(newChildRoles.sort()); \ No newline at end of file diff --git a/entity/RoleChildren_entity/recordcontainers/jdito/contentProcess.js b/entity/RoleChildren_entity/recordcontainers/jdito/contentProcess.js index cf0d3c41b7ee397447c6b35fc95c8a5a5f2c6f62..f21fb44def8424121f454521bd9e67d5f87b43ac 100644 --- a/entity/RoleChildren_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/RoleChildren_entity/recordcontainers/jdito/contentProcess.js @@ -9,15 +9,14 @@ var parentRoleName = vars.exists("$param.RoleId_param") && vars.get("$param.Role var children = []; if (parentRoleName && parentRoleName.indexOf("CUSTOM_") != -1) { - // parentRoleName is a viable CUSTOM role - var sqlStr = "select CHILD_ROLE, ID from ASYS_ROLES_CHILDREN where PARENT_ROLE = '" + parentRoleName + "'"; - var childRoles = db.table(sqlStr, alias); - if (childRoles.length != 0) { - for each (let childRole in childRoles) { - children.push([childRole[1], childRole[0], parentRoleName]); - } - } else { - children.push(["", "", parentRoleName]); + // roles can only be assigned to CUSTOM roles -> parent role has to be a viable CUSTOM role + childRoles = newSelect("ID, CHILD_ROLE", alias) + .from("ASYS_ROLES_CHILDREN") + .where("ASYS_ROLES_CHILDREN.PARENT_ROLE", parentRoleName) + .table(); + + for each (let childRole in childRoles) { + children.push([childRole[0], childRole[1], parentRoleName]); } var ids = vars.get("$local.idvalues"); diff --git a/entity/RoleChildren_entity/recordcontainers/jdito/onInsert.js b/entity/RoleChildren_entity/recordcontainers/jdito/onInsert.js index 7fec6ad58d90022619c620cca93d6680a81199a7..60f0bfa215505465723f41d8a605a430a1ccd9da 100644 --- a/entity/RoleChildren_entity/recordcontainers/jdito/onInsert.js +++ b/entity/RoleChildren_entity/recordcontainers/jdito/onInsert.js @@ -9,7 +9,6 @@ var parentRoleName = vars.exists("$param.RoleId_param") && vars.get("$param.Role if (parentRoleName && parentRoleName.indexOf("CUSTOM_") != -1) { var alias = SqlUtils.getSystemAlias(); var childRole = vars.get("$local.rowdata")["CHILD_ROLE.value"]; - - var uid = util.getNewUUID(); + var uid = vars.get("$field.UID") db.insertData("ASYS_ROLES_CHILDREN", ["CHILD_ROLE", "PARENT_ROLE", "ID"], null, [childRole, parentRoleName, uid], alias); } \ No newline at end of file