diff --git a/entity/VisitPlanEntry_entity/VisitPlanEntry_entity.aod b/entity/VisitPlanEntry_entity/VisitPlanEntry_entity.aod index b640c523a50c0f5ab6bd1a30a7f71ad6015ec7cd..e8c7c0ba81498ca831f90418e5fc1eac4daa7236 100644 --- a/entity/VisitPlanEntry_entity/VisitPlanEntry_entity.aod +++ b/entity/VisitPlanEntry_entity/VisitPlanEntry_entity.aod @@ -36,7 +36,6 @@ <title>Organisation</title> <consumer>Organisations</consumer> <mandatory v="true" /> - <stateProcess>%aditoprj%/entity/VisitPlanEntry_entity/entityfields/organisation_contact_id/stateProcess.js</stateProcess> <valueProcess>%aditoprj%/entity/VisitPlanEntry_entity/entityfields/organisation_contact_id/valueProcess.js</valueProcess> <displayValueProcess>%aditoprj%/entity/VisitPlanEntry_entity/entityfields/organisation_contact_id/displayValueProcess.js</displayValueProcess> </entityField> diff --git a/entity/VisitPlanEntry_entity/entityfields/contact_id/valueProcess.js b/entity/VisitPlanEntry_entity/entityfields/contact_id/valueProcess.js index 5862792995d91242c28595f94f85a6c6628ebd56..357a96238802b8f34c00a088b3fd1a3415dc0ff9 100644 --- a/entity/VisitPlanEntry_entity/entityfields/contact_id/valueProcess.js +++ b/entity/VisitPlanEntry_entity/entityfields/contact_id/valueProcess.js @@ -1,9 +1,19 @@ +import("Sql_lib"); import("system.logging"); import("system.neon"); import("system.result"); import("system.vars"); + + if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && (vars.get("$this.value") == null || vars.get("$this.value") == undefined)) - result.string(vars.get("$param.ContactId_param")); +{ + var isPersonContact = newSelect("PERSON.PERSONID").from("PERSON") + .join("CONTACT", "PERSON.PERSONID = CONTACT.PERSON_ID") + .where("CONTACT.CONTACTID", vars.get("$param.ContactId_param")).cell() + + if(isPersonContact) + result.string(vars.get("$param.ContactId_param")); +} diff --git a/entity/VisitPlanEntry_entity/entityfields/organisation_contact_id/stateProcess.js b/entity/VisitPlanEntry_entity/entityfields/organisation_contact_id/stateProcess.js deleted file mode 100644 index 832f94c08cd6b525fa8a549e6332eea384362f65..0000000000000000000000000000000000000000 --- a/entity/VisitPlanEntry_entity/entityfields/organisation_contact_id/stateProcess.js +++ /dev/null @@ -1,10 +0,0 @@ -import("system.logging"); -import("system.neon"); -import("system.result"); -import("system.vars"); - -if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$this.value") == null - && vars.exists("$param.ContactId_param") && vars.get("$param.ContactId_param")) -{ - result.string(neon.COMPONENTSTATE_INVISIBLE); -} \ No newline at end of file diff --git a/entity/VisitPlanEntry_entity/entityfields/organisation_contact_id/valueProcess.js b/entity/VisitPlanEntry_entity/entityfields/organisation_contact_id/valueProcess.js index 8e22e5c11f08455e5f445c1fbd3d05e4a222cd75..2b90b668563cd3c022b2e3a32c9bab71c44f1783 100644 --- a/entity/VisitPlanEntry_entity/entityfields/organisation_contact_id/valueProcess.js +++ b/entity/VisitPlanEntry_entity/entityfields/organisation_contact_id/valueProcess.js @@ -1,3 +1,4 @@ +import("Sql_lib"); import("system.neon"); import("system.result"); import("system.vars"); @@ -5,5 +6,15 @@ import("system.vars"); if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$this.value") == null && vars.exists("$param.OrganisationId_param") && vars.get("$param.OrganisationId_param")) { - result.string(vars.get("$param.OrganisationId_param")); + + var OrgId = newSelect("CONTACT.ORGANISATION_ID").from("CONTACT") + .where("CONTACT.CONTACTID", vars.get("$param.OrganisationId_param")) + .cell() + + var contactIdWithoutPerson = newSelect("CONTACT.CONTACTID").from("CONTACT") + .where("CONTACT.ORGANISATION_ID", OrgId) + .and("CONTACT.PERSON_ID is null") + .cell() + + result.string(contactIdWithoutPerson); } \ No newline at end of file