Skip to content
Snippets Groups Projects
Commit 6d47c660 authored by Johannes Hörmann's avatar Johannes Hörmann
Browse files

fix person firstname / lastname changes

parent 59c32485
No related branches found
No related tags found
No related merge requests found
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
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment