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

Merge branch '1060551_FixStandardAdressWhenOrgChange' into '2020.2'

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

See merge request xrm/basic!408
parents c0a17574 df6c0518
No related branches found
No related tags found
No related merge requests found
......@@ -21,30 +21,10 @@ for (var i = 0; i < localChanged.length; i++) {
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 standardAddressId = new StandardObject("Address", null, "Person", vars.get("$field.PERSONID"))
.onPersonValueChange(vars.get("$field.ORGANISATION_ID"));
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);
}
}
newWhere("CONTACT.CONTACTID", vars.get("$field.CONTACTID")).updateData(true, "CONTACT", ["ADDRESS_ID"], null, [standardAddressId])
}
var rowdata = vars.get("$local.rowdata");
......
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