diff --git a/entity/Person_entity/recordcontainers/db/recordfieldmappings/organisations/filterConditionProcess.js b/entity/Person_entity/recordcontainers/db/recordfieldmappings/organisations/filterConditionProcess.js index b2c8e025af01c5e7d8923b37a66bd59c183772c4..58155b84d17f2216b8d6d66dec19287ff34fa5e7 100644 --- a/entity/Person_entity/recordcontainers/db/recordfieldmappings/organisations/filterConditionProcess.js +++ b/entity/Person_entity/recordcontainers/db/recordfieldmappings/organisations/filterConditionProcess.js @@ -1,10 +1,9 @@ import("system.vars"); import("system.result"); -var sqlStr = "select PERSON_ID from CONTACT where ORGANISATION_ID in " + - " (select CONTACT.ORGANISATION_ID from CONTACT " + - " join ORGANISATION on (ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID) " + - " where PERSON_ID is null and " + vars.get("$local.condition") + ")" + - " and PERSON_ID is not null"; +//it's necessary to join the organistion-contact since you may want to search for things like status, language, etc. from an organisation +var from = "CONTACT PersonContact\n\ + join ORGANISATION on (ORGANISATION.ORGANISATIONID = PersonContact.ORGANISATION_ID)\n\ + join CONTACT on (ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID and CONTACT.PERSON_ID is null)"; -result.string("PERSONID in (" + sqlStr + ")"); \ No newline at end of file +result.string("PERSONID in (select PersonContact.PERSON_ID from " + from + " where " + vars.get("$local.condition")+ ")"); \ No newline at end of file