From 6d47c6602d6f5ef6d56e6bfdd98d71750daf685e Mon Sep 17 00:00:00 2001 From: Johannes Hoermann <j.hoermann@adito.de> Date: Tue, 23 Jul 2019 16:55:19 +0200 Subject: [PATCH] fix person firstname / lastname changes --- .../recordcontainers/db/onDBInsert.js | 2 +- .../recordcontainers/db/onDBUpdate.js | 22 ++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/entity/Person_entity/recordcontainers/db/onDBInsert.js b/entity/Person_entity/recordcontainers/db/onDBInsert.js index 157ddf8314..e9c6aaf6f7 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 530c2f5d46..243f0443fb 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 -- GitLab