diff --git a/entity/Person_entity/recordcontainers/db/onDBInsert.js b/entity/Person_entity/recordcontainers/db/onDBInsert.js index 157ddf8314dc0dcbcad97150a81ff52e25c50f7b..e9c6aaf6f72398df97745ae9e1ac87fd4e976392 100644 --- a/entity/Person_entity/recordcontainers/db/onDBInsert.js +++ b/entity/Person_entity/recordcontainers/db/onDBInsert.js @@ -1,4 +1,4 @@ import("system.vars"); import("DataPrivacy_lib"); -DataPrivacyUtils.notifyNeedDataPrivacyUpdate(vars.get("$field.CONTACTID")); \ No newline at end of file +DataPrivacyUtils.notifyNeedDataPrivacyUpdate(vars.get("$local.uid")); \ No newline at end of file diff --git a/entity/Person_entity/recordcontainers/db/onDBUpdate.js b/entity/Person_entity/recordcontainers/db/onDBUpdate.js index 530c2f5d46b93d85f6ee09373a336219671aad49..243f0443fb13fbf4db44de0800dbf415e2e973da 100644 --- a/entity/Person_entity/recordcontainers/db/onDBUpdate.js +++ b/entity/Person_entity/recordcontainers/db/onDBUpdate.js @@ -1,3 +1,4 @@ +import("system.logging"); import("DataPrivacy_lib"); import("system.tools"); import("system.vars"); @@ -6,8 +7,10 @@ import("Communication_lib"); import("Entity_lib"); import("StandardObject_lib"); +var rowdata = vars.get("$local.rowdata"); +logging.log(JSON.stringify(rowdata, null, "\t")) // TODO: this is a workaround for missing possibility to react on changes of fields not connected to record Contqainer #1030023 -var uid = vars.get("$sys.uid"); +var uid = rowdata["CONTACT.CONTACTID"]; FieldChanges.assimilateChangeAndDispose("$field.STANDARD_EMAIL_COMMUNICATION", function(state, value){ CommUtil.setStandardMail(uid, value); }); @@ -16,8 +19,8 @@ FieldChanges.assimilateChangeAndDispose("$field.STANDARD_PHONE_COMMUNICATION", f CommUtil.setStandardPhone(uid, value); }); -new StandardObject("Address", vars.get("$field.ADDRESS_ID"), "Person", vars.get("$field.CONTACTID")) - .onPersonUpdate(vars.get("$field.ORGANISATION_ID")); +new StandardObject("Address", rowdata["CONTACT.ADDRESS_ID"], "Person", uid) + .onPersonUpdate(rowdata["CONTACT.ORGANISATION_ID"]); var updates = []; @@ -26,12 +29,15 @@ vars.get("$local.changed").forEach(function(fieldName) { switch (fieldName) { case "PERSON.FIRSTNAME": case "PERSON.LASTNAME": - var user = tools.getUserByAttribute(tools.CONTACTID, [vars.get("$field.CONTACTID")], tools.PROFILE_FULL); - user[tools.PARAMS][tools.FIRSTNAME] = vars.get("$field.FIRSTNAME"); - user[tools.PARAMS][tools.LASTNAME] = vars.get("$field.LASTNAME"); - tools.updateUser(user); + var user = tools.getUserByAttribute(tools.CONTACTID, [uid], tools.PROFILE_FULL); + if (user) + { + user[tools.PARAMS][tools.FIRSTNAME] = rowdata[fieldName]; + user[tools.PARAMS][tools.LASTNAME] = rowdata[fieldName]; + tools.updateUser(user); + } break; } }) -DataPrivacyUtils.notifyNeedDataPrivacyUpdate(vars.get("$field.CONTACTID")); \ No newline at end of file +DataPrivacyUtils.notifyNeedDataPrivacyUpdate(uid); \ No newline at end of file