From bdaedf1258ab8e79c69e410260f8ba93d8805082 Mon Sep 17 00:00:00 2001 From: Johannes Hoermann <j.hoermann@adito.de> Date: Fri, 12 Apr 2019 16:47:44 +0200 Subject: [PATCH] salesproject: no state check on postponed when in recordstate new --- .../entityfields/state/onValueChange.js | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/entity/Salesproject_entity/entityfields/state/onValueChange.js b/entity/Salesproject_entity/entityfields/state/onValueChange.js index 7f831d53c9..fd8dae9d66 100644 --- a/entity/Salesproject_entity/entityfields/state/onValueChange.js +++ b/entity/Salesproject_entity/entityfields/state/onValueChange.js @@ -7,19 +7,22 @@ import("system.translate"); import("system.question"); import("system.neon"); -var state = vars.get("$field.STATE"); - -// Postponed -if (state == '23d38486-4cce-41ce-a8df-164ad44df706') +if (vars.get("$sys.recordstate") != neon.OPERATINGSTATE_NEW) { - var stateName = KeywordUtils.getViewValue($KeywordRegistry.salesprojectState(), state); - var clearForecast = question.askYesNo(translate.withArguments("Clear forecast and set state to '%0'?", [stateName]), translate.withArguments("Would you really like to clear the forecast and set the state to '%0'?" + "\n" + translate.text("This cannot be undone!"), [stateName]), false); - - if (!clearForecast) + var state = vars.get("$field.STATE"); + + // Postponed + if (state == '23d38486-4cce-41ce-a8df-164ad44df706') { - // reset to value from db - neon.setFieldValue("$field.STATE", db.cell(SqlCondition.begin() - .andPrepareVars("SALESPROJECT.SALESPROJECTID", "$field.SALESPROJECTID") - .buildSql("select STATE from SALESPROJECT", "1=2"))); + var stateName = KeywordUtils.getViewValue($KeywordRegistry.salesprojectState(), state); + var clearForecast = question.askYesNo(translate.withArguments("Clear forecast and set state to '%0'?", [stateName]), translate.withArguments("Would you really like to clear the forecast and set the state to '%0'?" + "\n" + translate.text("This cannot be undone!"), [stateName]), false); + + if (!clearForecast) + { + // reset to value from db + neon.setFieldValue("$field.STATE", db.cell(SqlCondition.begin() + .andPrepareVars("SALESPROJECT.SALESPROJECTID", "$field.SALESPROJECTID") + .buildSql("select STATE from SALESPROJECT", "1=2"))); + } } } -- GitLab