Add company address contact
See also: Addresses, Contact type, Address (Events), 'Add as company contact' button
Event action – Abstract
Purpose: Assigns an address present as a reference object to a company account as an address contact with a specific Contact type.
The Adresse als Kontakt einer Firma hinzufügen event action can be performed with an entity of the 'Address' type as a reference object. This action can be used to assign the address to a company account (see Company accounts) as an address contact with a specific Contact type.
The following rules apply:
An address is added only if it is not previously assigned as an address contact for the same Contact type within the address of the company account.
Unless the Contact type in the dynamic enumeration qualifies as 'plural', an added address contact replaces an existing one for the same Contact type.
►NOTE◄
Adding an address as an address contact for the Target company implies saving the relevant company account if its address does not yet contain the combination of address ID and Contact type (see rule no. 1 above).
For the account of the Target company, either the 'Change' (existing company account) or 'Create' (new company account) event is triggered when saving.
If the relevant access rights ('Change' or 'Create') for the account of the Target company are missing, the event handling will cancel with an error (incl. rollback).
If there is no suitable value for at least one of the Contact type or Target company parameters (see 'Configuration') at runtime, the event handling will cancel with an error (incl. rollback).
Special application case:
In Input forms, the Button "Als Kontakt der Firma hinzufügen can be used to trigger the 'Add address' event ( 'Address' form element) for a 'Company and address attribute' in the context of an address search (see Address (Events)).
This button can be used if the address search via Combobox deviates from the default and does not refer to addressbook entries but to address contacts of a certain company. The link to the company must be established at runtime via the Use contacts of this company action. Usually, this happens as a reaction to the selection of the company in another Combobox element (for details see the 'Add as company contact' button).
The event primarily passes the relevant address as an input value. In addition, further data from the call context is provided in variables:
Variable name |
Data type |
Content |
contactCompanyId |
Long |
ID of the company whose address contacts were offered in the form in the Combobox for the address search. |
contactTypes |
Contact type list |
List of all contact types selected as relevant in the service configuration for this Combobox. |
contactType |
Contact type (ContactType) |
The first entry (Contact type) of the list in the variable contactTypes. |
Provided that exactly one relevant Contact type is selected in the address search, the variables contactType and contactCompanyId can be transferred directly to the Contact type and Target company parameters in the event action Adresse als Kontakt einer Firma hinzufügen.
If the address search refers to more than one Contact type, the event handler must make a determination or – if necessary, taking into account the list in the contactTypes variable – query the user (see 'Special application case' example below).
'Address contact' background
An address contact (addressContact) is a typed attribute that is only offered for Addresses (see also 'Address contact' form element). Each address contact must be assigned a (sub)type from the dynamic enumeration Contact type. Depending on the 'plural' option for the Contact type in the dynamic enumeration, it can occur only once or multiple times in the same address. The value of an address contact attribute is the embedded 'address' (address) in the field of the same name.
►IMPORTANT◄ Addresses are handled in Lobster Data Platform / Orchestration as Referenced objects whose ID changes when address characteristics change. An address contact added via the Adresse als Kontakt einer Firma hinzufügen event action refers to a specific address ID and thus a specific combination of characteristics for address data. If the address to be added is 'read' from an existing data object, no link to this origin object is created. Changes to the address data in the origin object therefore do not affect a created address contact, but change the address ID in the origin object, while the address contact continues to refer to the original address ID until address details are changed by accessing the address field in the address contact. Operationally, the event action Adresse als Kontakt einer Firma hinzufügen therefore acts similarly to adding a snapshot of the address from the origin object as an address contact.
Configuration
►IMPORTANT◄ The address added to a company account as an address contact must exist as a reference object for the event action. Unless the event handling is executed as a whole with an entity of the 'Address' type as the input value, a context with a suitable reference object must first be defined for the execution of the event action. This allows e.g. event actions like Execute with or if necessary a For each loop over a list of addresses.
►NOTE◄ If there is no value or an unsuitable value for at least one of these parameters at runtime, the event handling terminates with an error message (and rollback if necessary). |
|
Examples
General application case
In a B2B portal implemented with Lobster Data Platform / Orchestration, the operator would like to create and manage company accounts for its business customers for logging into the portal. The administration of these company accounts is the task of 'account managers' at the operator, for whom a separate role 'CustomerAccountManager' has been set up for this purpose.
When saving (creating or modifying) a company account by a user who uses the 'CustomerAccountManager' role, the address from his user account should be automatically added as an address contact in the company account in question. The Contact type 'Account manager' (with the internal name ACCOUNT_MANAGER) is specified, which was created especially for this purpose. There should always be exactly one 'account manager' responsible for each customer. An existing address contact for the Contact type 'Account manager' should therefore always be replaced if a different address is added for the same Contact type.
►NOTE◄ For a practical application, it is important to take into account that the address in the added address contact matches the address in the user account only until an address feature is changed (see 'Background' infobox above). If the address in the user account is changed after the address contact has been added, the address ID referenced by the user account changes, while the address contact still references the original address ID and displays its data unchanged. An update or synchronization would require additional precautions.
Runtime example:
The user 'Karola Mustermann' is logged in for the portal operator (Xflow AG) as 'CustomerAccountManager' and accesses the company account of a customer company via the 'Companyaccount overview:'
|
|
As soon as the processing of the company account for 'fast-or-furious Ltd.' is completed via Save (in the ribbon), 'Account manager' appears in the company account, which shows the address for the user account (see Users) of 'Karola Mustermann'. Only the name fields are displayed here, but the address contact provides access to the entire address, so that, for example, the e-mail function, can use the communication information it may contain. |
|
Configuration:
An event handler is created for the 'registration' of the user making the last change to a company account and configured as shown on the right:
|
|
►NOTE◄ The fact that the Target company is also the input value of the event handling is a coincidence. If the address of 'Karola Mustermann' in our example is not yet entered as an address contact of the 'Account manager' type, the 'Update' event for the company account will be triggered twice, because the address contact is added again. |
|
Special application case
The following example demonstrates the use of the Adresse als Kontakt einer Firma hinzufügen event handling in connection with the 'Add as company contact' button triggering event 'Add address' (see Address (Events)).
In the course of addressing a shipment, a company account is selected for the company and address attribute Loading party (Company type DPA) initially in order to be able to specify a precise pickup position (here: Loading party Address), which, if necessary, will subsequently be stored in the address of the same company and address attribute. When selecting the company for the Loading party, the action Use contacts of this company for the Combobox of the Loading party Address is executed in the entry form. In the example, this should then offer all address contacts with the Contact type 'Gate/Entrance' or 'Building' for selection, which are found in the company account of the selected company. Alternatively, a completely new Loading party address can also be entered. Via the 'Add as company contact' button, a newly entered or changed company address should be added as a contact. The user should be able to define the assigned Contact type for the address contact via context menu (see screenshot on the right) from the options relevant for the pickup address. |
|
Configuration:
The configuration of the collection form is not described in detail here. To understand the event handling configuration described below, it is only relevant that the service configuration for the Combobox element within the Loading party Address names the Contact types 'Gate/Entrance' and 'Building'. Therefore, only addresses referring to address contacts of the selected company belonging to one of these two types will appear in the dropdown for selection.
Therefore, when the 'Add as company contact' button is used to trigger the 'Add address' event for the Loading party Address, the contactTypes variable contains a list with these two contact types.
For the Triggering event 'Add address' (see Address (Events)) the event handling shown on the right is configured:
►NOTE◄ The already pre-assigned variable contactType is also specifically selected here as the target for the return object of the context menu, so that within the event action Adresse als Kontakt einer Firma hinzufügen for the parameter Contact type the value of the variable contactType can always be transferred. In the special case of a crash or timeout after opening the context menu, however, the Adresse als Kontakt einer Firma hinzufügen event action is then blocked from being executed at all, otherwise 'no value' is passed as Contact type, which leads to a crash with an error message (incl. rollback). |
|
After completion of the Execute with event action, which is only relevant if the Contact type is not uniquely predetermined, the address to be added is again considered the reference object. In this context, the event action Add company address contact is executed:
|
|