diff --git a/entity/Salesproject_entity/recordcontainers/db/onDBUpdate.js b/entity/Salesproject_entity/recordcontainers/db/onDBUpdate.js index c9dfa3fa5c396f3cfb5d459cf9c5f0f91db4a270..ad790b87680c57809b0a0eea2e71f54b7e9f0ed5 100644 --- a/entity/Salesproject_entity/recordcontainers/db/onDBUpdate.js +++ b/entity/Salesproject_entity/recordcontainers/db/onDBUpdate.js @@ -1,3 +1,4 @@ +import("system.datetime"); import("Workflow_lib"); import("Context_lib"); import("system.neon"); @@ -22,6 +23,7 @@ vars.get("$local.changed").forEach(function(fieldName) { switch (fieldName) { case "SALESPROJECT.PHASE": + typeValue = "SalesprojectPhase"; break; case "SALESPROJECT.STATUS": // Milestone @@ -97,6 +99,16 @@ vars.get("$local.changed").forEach(function(fieldName) { } }); +if(rowdata["SALESPROJECT.STATUS"] == $KeywordRegistry.salesprojectState$aborted() + || rowdata["SALESPROJECT.STATUS"] == $KeywordRegistry.salesprojectState$partialOrder() + || rowdata["SALESPROJECT.STATUS"] == $KeywordRegistry.salesprojectState$order() + || rowdata["SALESPROJECT.STATUS"] == $KeywordRegistry.salesprojectState$lost()) +{ + newWhere("SALESPROJECT_MILESTONE.SALESPROJECT_ID", "$local.uid") + .and("SALESPROJECT_MILESTONE.DATE_END is null") + .and("SALESPROJECT_MILESTONE.KIND", "SalesprojectPhase").updateData(true, "SALESPROJECT_MILESTONE", ["DATE_END"], null, [datetime.date()]); +} + var [serviceUrl, channelId] = newSelect(["SERVICE_URL", "GENERAL_CHANNELID"]) .from("MST_TEAM") .where("MST_TEAM.MST_TEAMID", "$field.MST_TEAM_ID")