Skip to content
Snippets Groups Projects
Commit 154d9319 authored by Sebastian Listl's avatar Sebastian Listl :speech_balloon:
Browse files

Merge branch '1060551_FixChangeStandardAddressOrgChange' into '2020.1'

[Projekt: Entwicklung - Neon][TicketNr.: 1060551][Standardadresse bleibt bei Firmenwechsel gleich]

See merge request xrm/basic!296
parents efa76c35 8daf340a
No related branches found
No related tags found
No related merge requests found
import("Sql_lib");
import("Workflow_lib");
import("DataPrivacy_lib");
import("system.tools");
import("system.neon");
import("system.vars");
import("Person_lib");
import("Communication_lib");
import("Entity_lib");
import("StandardObject_lib");
var localChanged = vars.get("$local.changed");
var orgChanged = false;
for (var i = 0; i < localChanged.length; i++) {
if(localChanged[i] == "CONTACT.ORGANISATION_ID")
{
orgChanged = true;
break;
}
}
if(orgChanged)
{
var orgAddressId = newSelect("CONTACT.ADDRESS_ID")
.from("CONTACT")
.where("CONTACT.ORGANISATION_ID", vars.get("$field.ORGANISATION_ID"))
.and("CONTACT.PERSON_ID is null")
.cell();
var addressId = vars.get("$field.ADDRESS_ID");
if(addressId != orgAddressId) //update standard address if the the organisation changed
{
var persAddress = newSelect("ADDRESS.ADDRESSID")
.from("ADDRESS")
.where("ADDRESS.CONTACT_ID", vars.get("$field.CONTACTID"))
.and("ADDRESS.ADDRESSID", addressId)
.cell();
if(!persAddress) // only when the standard address is from the organisation
{
var standardAddressId = new StandardObject("Address", null, "Person", vars.get("$field.PERSONID"))
.onPersonValueChange(vars.get("$field.ORGANISATION_ID"));
neon.setFieldValue("$field.ADDRESS_ID", standardAddressId);
}
}
}
var rowdata = vars.get("$local.rowdata");
// TODO: this is a workaround for missing possibility to react on changes of fields not connected to record Contqainer #1030023
var uid = rowdata["CONTACT.CONTACTID"];
......@@ -24,7 +64,7 @@ new StandardObject("Address", rowdata["CONTACT.ADDRESS_ID"], "Person", uid)
var updates = [];
// update user object if name changed
vars.get("$local.changed").forEach(function(fieldName)
localChanged.forEach(function(fieldName)
{
var nameProp = tools.LASTNAME;
switch (fieldName) {
......
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