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

set default address, if changing org of person

parent cb393b85
No related branches found
No related tags found
No related merge requests found
......@@ -337,6 +337,12 @@
</entityParameter>
</children>
</entityConsumer>
<entityParameter>
<name>ReloadWorkaround_param</name>
<expose v="true" />
<triggerRecalculation v="true" />
<description>PARAMETER</description>
</entityParameter>
</entityFields>
<recordContainers>
<dbRecordContainer>
......
......@@ -150,6 +150,7 @@
<valueProcess>%aditoprj%/entity/Person_entity/entityfields/organisation_id/valueProcess.js</valueProcess>
<displayValueProcess>%aditoprj%/entity/Person_entity/entityfields/organisation_id/displayValueProcess.js</displayValueProcess>
<onValidation>%aditoprj%/entity/Person_entity/entityfields/organisation_id/onValidation.js</onValidation>
<onValueChange>%aditoprj%/entity/Person_entity/entityfields/organisation_id/onValueChange.js</onValueChange>
</entityField>
<entityConsumer>
<name>PersAddresses</name>
......@@ -690,6 +691,11 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact
<entityParameter>
<name>ContactId_param</name>
<valueProcess>%aditoprj%/entity/Person_entity/entityfields/contactandorganisationaddresses/children/contactid_param/valueProcess.js</valueProcess>
<triggerRecalculation v="true" />
</entityParameter>
<entityParameter>
<name>OrganisationId_param</name>
<valueProcess>%aditoprj%/entity/Person_entity/entityfields/contactandorganisationaddresses/children/organisationid_param/valueProcess.js</valueProcess>
</entityParameter>
</children>
</entityConsumer>
......
......@@ -3,11 +3,12 @@ import("system.vars");
import("StandardObject_lib");
// Check if the standard address is already set.
if (vars.get("$field.ADDRESS_ID") === null || vars.get("$field.ADDRESS_ID") === "" || vars.get("$field.ADDRESS_ID") == 0) {
if (!vars.get("$field.ADDRESS_ID"))
{
var possibleStandardAddressID = new StandardObject("Address", null, "Person", vars.get("$field.PERSONID"))
.onPersonValueChange(vars.get("$field.ORGANISATION_ID"));
// If a possible standard addrss was found it should get applied to the field.
if (possibleStandardAddressID !== null)
if (possibleStandardAddressID)
result.string(possibleStandardAddressID);
}
\ No newline at end of file
import("system.vars");
import("system.result");
result.string(vars.get("$field.ORGANISATION_ID"));
\ No newline at end of file
import("system.logging");
import("system.result");
import("system.vars");
import("system.neon");
import("StandardObject_lib");
if (!vars.get("$field.ADDRESS_ID") || StandardObject.isOrganisationAddress(vars.get("$field.ADDRESS_ID")))
{
logging.log(vars.get("$field.ADDRESS_ID"))
var possibleStandardAddressID = new StandardObject("Address", null, "Person", vars.get("$field.PERSONID"))
.onPersonValueChange(vars.get("$field.ORGANISATION_ID"));
// If a possible standard addrss was found it should get applied to the field.
if (possibleStandardAddressID)
neon.setFieldValue("$field.ADDRESS_ID", possibleStandardAddressID);
}
\ No newline at end of file
......@@ -185,8 +185,8 @@ StandardObject.prototype.onCommunicationUpdate = function (pMediumID) {
* address it will return `true`, otherwise `false`. This function asserts that
* it's currently working on a `Address` object.
*
* @param pContactID Contact ID to check.
* @return If the contact ID has standard address.
* @param {String} pContactID Contact ID to check.
* @return {Boolean} If the contact ID has standard address.
*/
StandardObject.prototype._hasContactStandardAddress = function (pContactID) {
this._assertObjectType(StandardObject.CONST_OBJECT_ADDRESS());
......@@ -201,8 +201,8 @@ StandardObject.prototype._hasContactStandardAddress = function (pContactID) {
* Will set the given address ID on the given contact ID. This function asserts
* that it's currently working on an `Address` object.
*
* @param pAddressID New address ID to set on the contact.
* @param pContactID The contact ID to set the address ID on.
* @param {String} pAddressID New address ID to set on the contact.
* @param {String} pContactID The contact ID to set the address ID on.
*/
StandardObject.prototype._setContactStandardAddress = function (pAddressID, pContactID) {
// Assert.
......@@ -237,8 +237,8 @@ StandardObject.prototype._getCompanyStandardAddress = function (pOrganisationID)
* Checks if the given contact ID already has a standard set with the given medium
* category.
*
* @param pContactID {String} Contact ID to check.
* @param pMediumCategory {String} Medium category to check.
* @param {String} pContactID Contact ID to check.
* @param {String} pMediumCategory Medium category to check.
* @return {Boolean} If the contact already has a standard addres with the given
* medium category.
*/
......@@ -254,7 +254,7 @@ StandardObject.prototype._hasStandardCommunicationByMedium = function (pContactI
/**
* Resolves the given pMediumID with the category.
*
* @param pMediumID {String} ID of the medium to resolve.
* @param {String} pMediumID ID of the medium to resolve.
* @return {String} Resovled category.
*/
StandardObject.prototype._getMediumCategory = function (pMediumID) {
......@@ -267,8 +267,8 @@ StandardObject.prototype._getMediumCategory = function (pMediumID) {
* Will set the given communication ID as standard. (Will update the `STANDARD`
* column.)
*
* @param pCommunicationID {String} The communication ID to set as standard.
* @param pValue {Number} 0 or 1 (boolean)
* @param {String} pCommunicationID The communication ID to set as standard.
* @param {Number} pValue 0 or 1 (boolean)
*/
StandardObject.prototype._setStandardCommunication = function (pCommunicationID, pValue) {
// Assert.
......@@ -286,7 +286,7 @@ StandardObject.prototype._setStandardCommunication = function (pCommunicationID,
/**
* Will return the Contact ID by the given communication ID.
*
* @param pCommunicationID {String} Communication ID to get the contact ID for.
* @param {String} pCommunicationID to get the contact ID for.
* @return The contact ID.
*/
StandardObject.prototype._getContactIdByCommunication = function (pCommunicationID) {
......@@ -294,12 +294,22 @@ StandardObject.prototype._getContactIdByCommunication = function (pCommunication
}
StandardObject.prototype._isOrganisationAddress = function (pAddressID) {
return StandardObject.isOrganisationAddress(pAddressID);
}
/**
* Check if the address is a organisation address.
*
* @param {String} pAddressID Communication ID to get the contact ID for.
* @return The contact ID.
*/
StandardObject.isOrganisationAddress = function (pAddressID) {
var contactID = db.cell("select CONTACTID from CONTACT where ADDRESS_ID = '" + pAddressID + "'");
if (contactID === "")
if (!contactID)
return false;
var contactType = ContactUtils.getContactTypeByContactId(contactID);
return contactType === 1;
return contactType == 1;
}
\ 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