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

Update First-/Lastname of employee if Person name changed

parent 474f6226
No related branches found
No related tags found
No related merge requests found
import("system.tools");
import("system.vars");
import("Person_lib");
import("Communication_lib");
......@@ -15,4 +16,19 @@ FieldChanges.assimilateChangeAndDispose("$field.STANDARD_PHONE_COMMUNICATION", f
});
new StandardObject("Address", vars.get("$field.ADDRESS_ID"), "Person", vars.get("$field.CONTACTID"))
.onPersonUpdate(vars.get("$field.ORGANISATION_ID"));
\ No newline at end of file
.onPersonUpdate(vars.get("$field.ORGANISATION_ID"));
var updates = [];
// update user object if name changed
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);
break;
}
})
\ 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