diff --git a/entity/Offer_entity/Offer_entity.aod b/entity/Offer_entity/Offer_entity.aod index 0f57da59c153a56bb555e55212792c6558fd68bb..18b73ee9d79ca1d272ecba210f69d47f240fa849 100644 --- a/entity/Offer_entity/Offer_entity.aod +++ b/entity/Offer_entity/Offer_entity.aod @@ -930,7 +930,6 @@ <name>LETTERSALUTATION</name> <title>Letter salutation</title> <stateProcess>%aditoprj%/entity/Offer_entity/entityfields/lettersalutation/stateProcess.js</stateProcess> - <valueProcess>%aditoprj%/entity/Offer_entity/entityfields/lettersalutation/valueProcess.js</valueProcess> </entityField> <entityActionField> <name>openAdminView</name> diff --git a/entity/Offer_entity/entityfields/chosenaddress/valueProcess.js b/entity/Offer_entity/entityfields/chosenaddress/valueProcess.js index 6ebcf9a49b9f2a8d6f2a5b7f54b38fb6a2481fce..f2e8d829a6610c678b5bdd1ad4aa2afaf88acd87 100644 --- a/entity/Offer_entity/entityfields/chosenaddress/valueProcess.js +++ b/entity/Offer_entity/entityfields/chosenaddress/valueProcess.js @@ -3,7 +3,7 @@ import("system.result"); import("system.neon"); import("system.vars"); -if ((vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT) && !vars.get("$field.ADDRESS")) +if ((vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT)) { var defaultAddressId = ContactUtils.getDefaultAddressId(vars.get("$field.CONTACT_ID")); if (defaultAddressId) diff --git a/entity/Offer_entity/entityfields/contact_id/onValueChange.js b/entity/Offer_entity/entityfields/contact_id/onValueChange.js index 4d3ecbb18ee4bdbd45431fe3ea9b563c29dab08c..74fa8e077b78ed95d1e417ae9326c2ae2ff2d837 100644 --- a/entity/Offer_entity/entityfields/contact_id/onValueChange.js +++ b/entity/Offer_entity/entityfields/contact_id/onValueChange.js @@ -1,3 +1,4 @@ +import("PostalAddress_lib"); import("Sql_lib"); import("system.neon"); import("system.vars"); @@ -17,6 +18,17 @@ if(contactid != "") if(lang != "") neon.setFieldValue("field.ISOLANGUAGE", lang); + var defaultAddressId = ContactUtils.getDefaultAddressId(contactid); + if (defaultAddressId) + { + neon.setFieldValue("field.ChosenAddress", defaultAddressId); + neon.setFieldValue("$field.ADDRESS", AddressUtils.getAddressById(defaultAddressId)); + } + var addrobj = new AddrObject(contactid); + var salutation = addrobj.getFormattedAddress(false, "{letter_salutation},"); + if (salutation != "Err.,") + neon.setFieldValue("field.LETTERSALUTATION", salutation); + // set $field.CONTATCT_ORG_ID per contactid var orgid = ContactUtils.getPersOrgIds(contactid); neon.setFieldValue("$field.CONTACT_ORG_ID", orgid[2]); diff --git a/entity/Offer_entity/entityfields/lettersalutation/valueProcess.js b/entity/Offer_entity/entityfields/lettersalutation/valueProcess.js deleted file mode 100644 index c3b78386885faaaf9b3dcfe18c659d6bb76d9c46..0000000000000000000000000000000000000000 --- a/entity/Offer_entity/entityfields/lettersalutation/valueProcess.js +++ /dev/null @@ -1,12 +0,0 @@ -import("system.result"); -import("system.neon"); -import("system.vars"); -import("Address_lib"); - -if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$this.value") == null) -{ - var addrobj = new AddrObject(vars.get("$field.CONTACT_ID")); - var salutation = addrobj.getFormattedAddress(false, "{letter_salutation},"); - if (salutation != "Err.,") - result.string(salutation); -} \ No newline at end of file