From ff549a3caafebe1dc1406c4b8426b9fac195bf40 Mon Sep 17 00:00:00 2001 From: Johannes Goderbauer <j.goderbauer@adito.de> Date: Thu, 25 Jun 2020 13:28:55 +0200 Subject: [PATCH] Person: make salutation mandatory --- entity/Person_entity/Person_entity.aod | 1 + .../person_salutation/mandatoryProcess.js | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/entity/Person_entity/Person_entity.aod b/entity/Person_entity/Person_entity.aod index a4a627f938f..446f310d7bc 100644 --- a/entity/Person_entity/Person_entity.aod +++ b/entity/Person_entity/Person_entity.aod @@ -60,6 +60,7 @@ <name>SALUTATION</name> <title>Salutation</title> <consumer>Salutations</consumer> + <mandatory v="true" /> </entityField> <entityField> <name>TITLE</name> diff --git a/entity/QuickEntry_entity/entityfields/person_salutation/mandatoryProcess.js b/entity/QuickEntry_entity/entityfields/person_salutation/mandatoryProcess.js index c5a419766d5..612c7e81d16 100644 --- a/entity/QuickEntry_entity/entityfields/person_salutation/mandatoryProcess.js +++ b/entity/QuickEntry_entity/entityfields/person_salutation/mandatoryProcess.js @@ -2,9 +2,14 @@ import("system.logging"); import("system.result"); import("system.vars"); -var insertedRows = vars.get("$field.Adresses.insertedRows"); -var isInserted = insertedRows.some(function (row){ - return row["ZIP"] || row["CITY"] || row["ADDRESS"]; -}) +var isMandatory = false; +if (vars.get("$field.LASTNAME") != "") + isMandatory = true; +else { + var insertedRows = vars.get("$field.Adresses.insertedRows");//this is the list of person contact addresses + isMandatory = insertedRows.some(function (row){ + return row["ZIP"] || row["CITY"] || row["ADDRESS"]; + }); +} -result.string(isInserted); \ No newline at end of file +result.string(isMandatory); \ No newline at end of file -- GitLab