From 8a0b5fc01e16777f2f3e71a443e1a0a049aaba37 Mon Sep 17 00:00:00 2001 From: "j.goderbauer" <j.goderbauer@adito.de> Date: Wed, 27 Mar 2019 14:30:43 +0100 Subject: [PATCH] "new Contact" autoset private-dummy-org --- entity/Contact_entity/Contact_entity.aod | 2 +- .../entityfields/organisation_id/onValueChange.js | 8 +++++++- .../entityfields/organisation_id/valueProcess.js | 7 ++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/entity/Contact_entity/Contact_entity.aod b/entity/Contact_entity/Contact_entity.aod index 2525ff9c3b4..1bdf8914726 100644 --- a/entity/Contact_entity/Contact_entity.aod +++ b/entity/Contact_entity/Contact_entity.aod @@ -17,7 +17,7 @@ <name>ORGANISATION_ID</name> <title>Organisation</title> <consumer>Organisations</consumer> - <mandatory v="true" /> + <mandatory v="false" /> <valueProcess>%aditoprj%/entity/Contact_entity/entityfields/organisation_id/valueProcess.js</valueProcess> <displayValueProcess>%aditoprj%/entity/Contact_entity/entityfields/organisation_id/displayValueProcess.js</displayValueProcess> <onValidation>%aditoprj%/entity/Contact_entity/entityfields/organisation_id/onValidation.js</onValidation> diff --git a/entity/Contact_entity/entityfields/organisation_id/onValueChange.js b/entity/Contact_entity/entityfields/organisation_id/onValueChange.js index 0347a3d2d5b..80f1e97c873 100644 --- a/entity/Contact_entity/entityfields/organisation_id/onValueChange.js +++ b/entity/Contact_entity/entityfields/organisation_id/onValueChange.js @@ -1,4 +1,10 @@ import("system.vars"); +import("system.neon"); //since the standard address can be only values of org the standard address has to be reset on org change -vars.set("$field.ADDRESS_ID", ""); \ No newline at end of file +vars.set("$field.ADDRESS_ID", ""); + +if(vars.exists("$local.value") && !vars.get("$local.value")) +{ + neon.setFieldValue("$field.ORGANISATION_ID", "0"); +} diff --git a/entity/Contact_entity/entityfields/organisation_id/valueProcess.js b/entity/Contact_entity/entityfields/organisation_id/valueProcess.js index b25ed87f458..008844fbe52 100644 --- a/entity/Contact_entity/entityfields/organisation_id/valueProcess.js +++ b/entity/Contact_entity/entityfields/organisation_id/valueProcess.js @@ -2,10 +2,7 @@ import("system.result"); import("system.vars"); import("system.neon"); -if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && !vars.get("$this.value")) +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.getString("$field.ORGANISATION_ID") == "") { - if(!vars.get("$field.ORGANISATION_ID")) - { - result.string("0"); - } + result.string("0"); } \ No newline at end of file -- GitLab