diff --git a/entity/Address_entity/Address_entity.aod b/entity/Address_entity/Address_entity.aod index 133262e8066e544b6ebe904a1e6bdfdbbe7fef94..871854a52648ee83a5ca7a559eea276cac27aa8b 100644 --- a/entity/Address_entity/Address_entity.aod +++ b/entity/Address_entity/Address_entity.aod @@ -478,6 +478,10 @@ <name>ContactIds_param</name> <expose v="true" /> </entityParameter> + <entityParameter> + <name>ReplaceStandardAddress_param</name> + <expose v="true" /> + </entityParameter> </entityFields> <recordContainers> <dbRecordContainer> diff --git a/entity/Address_entity/recordcontainers/db/onDBInsert.js b/entity/Address_entity/recordcontainers/db/onDBInsert.js index 05aad0bca12d937d10ba335421077990d53a0fe4..26ad235d60c44f65193018e5430a980214dfed60 100644 --- a/entity/Address_entity/recordcontainers/db/onDBInsert.js +++ b/entity/Address_entity/recordcontainers/db/onDBInsert.js @@ -1,3 +1,4 @@ +import("system.logging"); import("KeywordRegistry_basic"); import("DataPrivacy_lib"); import("system.vars"); @@ -22,6 +23,6 @@ else if (typeParam === "organisation") scopeType = "Organisation" new StandardObject("Address", vars.get("$local.uid"), scopeType, rowdata["ADDRESS.CONTACT_ID"]) - .onObjectInsert() + .onObjectInsert(vars.exists("$param.ReplaceStandardAddress_param") ? vars.get("$param.ReplaceStandardAddress_param") : undefined) -DataPrivacyUtils.notifyNeedDataPrivacyUpdate(rowdata["ADDRESS.CONTACT_ID"], vars.get("$param.ShowDsgvoMessage_param")); \ No newline at end of file +DataPrivacyUtils.notifyNeedDataPrivacyUpdate(rowdata["ADDRESS.CONTACT_ID"], vars.get("$param.ShowDsgvoMessage_param")); diff --git a/entity/Person_entity/Person_entity.aod b/entity/Person_entity/Person_entity.aod index c8c9b4469fdac2b91adb9f3dc8f724b8a70d1c91..4d104964f8f23e728f79baf9c0b9f3107213ab54 100644 --- a/entity/Person_entity/Person_entity.aod +++ b/entity/Person_entity/Person_entity.aod @@ -176,6 +176,10 @@ This field only calculates the Orgid from the ORGANISATION_CONTACTID to save it <name>ShowDsgvoMessage_param</name> <valueProcess>%aditoprj%/entity/Person_entity/entityfields/persaddresses/children/showdsgvomessage_param/valueProcess.js</valueProcess> </entityParameter> + <entityParameter> + <name>ReplaceStandardAddress_param</name> + <valueProcess>%aditoprj%/entity/Person_entity/entityfields/persaddresses/children/replacestandardaddress_param/valueProcess.js</valueProcess> + </entityParameter> </children> </entityConsumer> <entityConsumer> diff --git a/entity/Person_entity/entityfields/persaddresses/children/replacestandardaddress_param/valueProcess.js b/entity/Person_entity/entityfields/persaddresses/children/replacestandardaddress_param/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..41522d06159dc6b95252b269220319760dcd36fa --- /dev/null +++ b/entity/Person_entity/entityfields/persaddresses/children/replacestandardaddress_param/valueProcess.js @@ -0,0 +1,8 @@ +import("system.neon"); +import("system.vars"); +import("system.result"); + +//this parameter allows the address entity to set a itself as the standard address +//if the current standard address is the given id +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) + result.string(vars.get("$field.ADDRESS_ID")); \ No newline at end of file diff --git a/entity/Person_entity/recordcontainers/db/onDBInsert.js b/entity/Person_entity/recordcontainers/db/onDBInsert.js index eb22217f25b73bf8443d32cae8969d7ec4aea56a..5f069680c3cd50ac7a7b062d6a9c55a22a176dcc 100644 --- a/entity/Person_entity/recordcontainers/db/onDBInsert.js +++ b/entity/Person_entity/recordcontainers/db/onDBInsert.js @@ -72,4 +72,6 @@ notification.addNotificationWith(notificationConfig); //notification.addNotification(util.getNewUUID(), null, null, null, "_____SYSTEM_NOTIFICATION_MESSAGE", notification.PRIO_NORMAL, 1, notification.STATE_UNSEEN, [EmployeeUtils.getCurrentUserId()], "message", "description"); -} \ No newline at end of file +} + +var persAdress \ No newline at end of file diff --git a/process/StandardObject_lib/process.js b/process/StandardObject_lib/process.js index 5e8a368ff6f34abf5c60fb08ce0b39828d117350..acd3d10fab7293f53014b0b30a9ac436fd3692ab 100644 --- a/process/StandardObject_lib/process.js +++ b/process/StandardObject_lib/process.js @@ -1,4 +1,5 @@ import("Organisation_lib"); +import("Sql_lib"); import("system.db"); import("Keyword_lib"); import("KeywordRegistry_basic"); @@ -111,12 +112,12 @@ StandardObject.prototype.onPersonValueChange = function (pSelectedOrganisationID * on a "random" basis: Which object gets first inserted will get the * place as standard. */ -StandardObject.prototype.onObjectInsert = function () { +StandardObject.prototype.onObjectInsert = function (pIdToOverwrite) { this._assertObjectIdNotNull(); this._assertScopeIdNotNull(); if (this.objectType === StandardObject.CONST_OBJECT_ADDRESS()) { - this._onAddressInsert(); + this._onAddressInsert(pIdToOverwrite); } else if (this.objectType === StandardObject.CONST_OBJECT_COMMUNICATION) { this._onCommunicationInsert(); } @@ -127,11 +128,11 @@ StandardObject.prototype.onObjectInsert = function () { * of the `Address` entity. This will set the standard address on the * contact if it's currently null. */ -StandardObject.prototype._onAddressInsert = function () { +StandardObject.prototype._onAddressInsert = function (pIdToOverwrite) { // Assert this._assertObjectType(StandardObject.CONST_OBJECT_ADDRESS()); - if (!this._hasContactStandardAddress(this.scopeID)) { + if (!this._hasContactStandardAddress(this.scopeID, pIdToOverwrite)) { this._setContactStandardAddress(this.objectID, this.scopeID); } } @@ -190,15 +191,16 @@ StandardObject.prototype.onCommunicationUpdate = function (pMediumID) { * it's currently working on a `Address` object. * * @param {String} pContactID Contact ID to check. + * @param {String} [pIdToIgnore] if this address ID is found, act as if it was empty * @return {Boolean} If the contact ID has standard address. */ -StandardObject.prototype._hasContactStandardAddress = function (pContactID) { +StandardObject.prototype._hasContactStandardAddress = function (pContactID, pIdToIgnore) { this._assertObjectType(StandardObject.CONST_OBJECT_ADDRESS()); var databaseResult = db.cell("select ADDRESS_ID from CONTACT" + " where CONTACTID = '" + pContactID + "'"); - - return databaseResult !== ""; + + return databaseResult !== "" && databaseResult !== pIdToIgnore; } /**