diff --git a/entity/Attribute_entity/entityfields/dropdownfilter/valueProcess.js b/entity/Attribute_entity/entityfields/dropdownfilter/valueProcess.js index 83bdb17d2622ba877e06fa3ecca9d7d80cd57dc1..c040a5fb10889419eec6902e9663603a8c1e2489 100644 --- a/entity/Attribute_entity/entityfields/dropdownfilter/valueProcess.js +++ b/entity/Attribute_entity/entityfields/dropdownfilter/valueProcess.js @@ -3,12 +3,20 @@ import("system.vars"); import("system.result"); import("Attribute_lib"); -var thisValueNotValid = "{\"entity\":\"\",\"filter\":{\"type\":\"group\",\"operator\":\"AND\",\"childs\":[]}}"; - -if (vars.get("$field.DROPDOWNDEFINITION") == $AttributeTypes.OBJECTSELECTION - && vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && (vars.get("$this.value") == null || vars.get("$this.value") == thisValueNotValid)) +if (vars.get("$field.ATTRIBUTE_TYPE").trim() == $AttributeTypes.OBJECTSELECTION + && (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)) { var entity = vars.getString("$field.DROPDOWNDEFINITION"); - var condJson = JSON.stringify({entity: entity, filter: {type: "group", operator: "AND", childs: []}}); - result.string(condJson); + var emptyFilter = {entity: entity, filter: {type: "group", operator: "AND", childs: []}}; + + var currentFilter = vars.get("$this.value"); + if (currentFilter) + currentFilter = JSON.parse(currentFilter); + + //if the filter field is empty or if the entity was changed, reset the filter + if (!vars.get("$this.value") || currentFilter.entity != emptyFilter.entity) + { + var condJson = JSON.stringify(emptyFilter); + result.string(condJson); + } } \ No newline at end of file diff --git a/process/Attribute_lib/process.js b/process/Attribute_lib/process.js index f517199cb89a28fecd0ad51ffb24643571c99038..73a5f9a4ac9b1085510626d84184e98e3b629a4b 100644 --- a/process/Attribute_lib/process.js +++ b/process/Attribute_lib/process.js @@ -183,8 +183,12 @@ AttributeUtil.getPossibleListValues = function (pAttributeId, pAttributeType, pI var config = entities.createConfigForLoadingRows() .entity(module) .fields([uid, title]); - if (filter && filter.filter) - config.filter(filter.filter); + if (filter) + { + filter = JSON.parse(filter); + if (filter.filter) + config.filter(JSON.stringify(filter.filter)); + } var rows = entities.getRows(config); for (let i = 0, l = rows.length; i < l; i++) objects.push([rows[i][uid], rows[i][title]])