diff --git a/entity/Organisation_entity/recordcontainers/db/onDBDelete.js b/entity/Organisation_entity/recordcontainers/db/onDBDelete.js index df7ebcfc65ce91ebe3df47be55e4f6d59813c916..cb4a6f482b82a7f0c2b321145999397dd7dfd9d2 100644 --- a/entity/Organisation_entity/recordcontainers/db/onDBDelete.js +++ b/entity/Organisation_entity/recordcontainers/db/onDBDelete.js @@ -12,7 +12,8 @@ DuplicateScannerUtils.deleteHasDuplicateEntries(EntityUtils.getCurrentEntitytId( new AttributeRelationQuery(contactId, null, ContextUtils.getCurrentContextId()) .deleteAllAttributes(); -newWhere("COMMUNICATION.CONTACT_ID", contactId).deleteData(); +newWhere("COMMUNICATION.OBJECT_ROWID", contactId) +.and("COMMUNICATION.OBJECT_TYPE", "Contact").deleteData(); newWhere("ADDRESS.CONTACT_ID", contactId).deleteData(); newWhere("COMMUNICATIONSETTINGS.CONTACT_ID", contactId).deleteData(); newWhere("CLASSIFICATIONSTORAGE.OBJECT_ROWID", contactId).deleteData(); diff --git a/process/Contact_lib/process.js b/process/Contact_lib/process.js index 44f60495091428eed2ec7b7b023cff93f24183d7..0c931e6f6b4477cbb0490512d9f1fa287c764264 100644 --- a/process/Contact_lib/process.js +++ b/process/Contact_lib/process.js @@ -768,7 +768,7 @@ ContactUtils.getContactIdByEmail = function(pEmail) var email = EmailUtils.extractAddress(pEmail).toUpperCase(); var contactId = newSelect("CONTACT.CONTACTID") .from("COMMUNICATION") - .join("CONTACT", "COMMUNICATION.CONTACT_ID = CONTACT.CONTACTID") + .join("CONTACT", newWhere("COMMUNICATION.OBEJCT_ROWID = CONTACT.CONTACTID").and("COMMUNICATION.OBJECT_TYPE", "Contact")) .where("COMMUNICATION.ADDR", email, "upper(#) = ?") .cell(); return contactId; diff --git a/process/EmailFilterHandling_lib/process.js b/process/EmailFilterHandling_lib/process.js index 156337cb248ad8e26698309f16ad387d86c62fd1..afbc40f1ac400c2da386905d844624b1fca55f34 100644 --- a/process/EmailFilterHandling_lib/process.js +++ b/process/EmailFilterHandling_lib/process.js @@ -124,9 +124,10 @@ IncomingEmailFilterProcessor.prototype.checkBodyForIds = function (pEmail) //if no maillog was found at least match the mailaddress to a contact if(!mailLogId && mailAddress) { - contactId = newSelect("COMMUNICATION.CONTACT_ID") + contactId = newSelect("COMMUNICATION.OBJECT_ROWID") .from("COMMUNICATION") .where("COMMUNICATION.ADDR",mailAddress) + .and("COMMUNICATION.OBJECT_TYPE", "Contact") .cell() } diff --git a/process/register_rest/process.js b/process/register_rest/process.js index 9c9ae2bebdba0da5d71ba0cc4792b3ebcff016f6..ecc5f3f8f04262f8921e5327b1ef969cbe8afc6d 100644 --- a/process/register_rest/process.js +++ b/process/register_rest/process.js @@ -48,7 +48,7 @@ function _findPerson(pFirstname, pLastname, pMailAddress) var contactId = newSelect("CONTACT.CONTACTID") .from("CONTACT") .join("PERSON","CONTACT.PERSON_ID = PERSON.PERSONID") - .join("COMMUNICATION","COMMUNICATION.CONTACT_ID = CONTACT.CONTACTID") + .join("COMMUNICATION",newWhere("COMMUNICATION.OBJECT_ROWID = CONTACT.CONTACTID").and("COMMUNICATION.OBJECT_TYPE", "Contact")) .whereIfSet("PERSON.FIRSTNAME",pFirstname) .andIfSet("PERSON.LASTNAME",pLastname) .and("COMMUNICATION.MEDIUM_ID",$KeywordRegistry.communicationMedium$mail()) @@ -58,7 +58,7 @@ function _findPerson(pFirstname, pLastname, pMailAddress) if (!contactId){ contactId = newSelect("CONTACT.CONTACTID") .from("CONTACT") - .join("COMMUNICATION","COMMUNICATION.CONTACT_ID = CONTACT.CONTACTID") + .join("COMMUNICATION",newWhere("COMMUNICATION.OBJECT_ROWID = CONTACT.CONTACTID").and("COMMUNICATION.OBJECT_TYPE", "Contact")) .where("COMMUNICATION.MEDIUM_ID",$KeywordRegistry.communicationMedium$mail()) .and("COMMUNICATION.ADDR",pMailAddress) .and("CONTACT.PERSON_ID is not null") @@ -109,12 +109,13 @@ function _insertPerson(pFirstname, pLastname, pMailAddress, pSalutation) .tableName("COMMUNICATION") .insertFields({ "COMMUNICATIONID": util.getNewUUID(), - "CONTACT_ID" : contactId, + "OBJECT_ROWID" : contactId, "MEDIUM_ID": $KeywordRegistry.communicationMedium$mail(), "ADDR": pMailAddress, "ISSTANDARD" : "1", "USER_NEW": "register_rest", - "DATE_NEW": vars.get("$sys.date") + "DATE_NEW": vars.get("$sys.date"), + "OBJECT_TYPE" : "Contact" }); return contactId;