Create instance

Value resolver – Abstract

Purpose: Creates a new instance, i.e. a 'volatile' data object, for the specific Type statically selected in the configuration.

See also: Create instance with values, Copy instance

images/download/attachments/201662370/image-2025-3-17_7-30-20-version-1-modificationdate-1742193019994-api-v2.png

The Create instance value resolver creates a new instance, i.e. a 'volatile' data object, for the specific Type statically selected in the configuration.

The input value is ignored.

If the creation of the data object is successful, it will be returned.

If the creation fails, 'no value' ($null) is returned in the following cases:

  • No Type was specified.

  • The selected Type is non-specific, e.g. the overarching class for all entities: 'Entity'. (de.lobster.scm.entity.Entity).

  • The selected Type is not known in the context of the Lobster Data Platform / Orchestration installation, because it concerns a module that is not installed.

  • The selected Type is not known in the context of the Lobster Data Platform / Orchestration installation because an incorrect class name was entered as free text instead of a selection (e.g. cutsom.myTypo instead of custom.myType).

images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/warning.svg CAUTIONimages/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/warning.svg If a class for static or dynamic enumeration values (e.g. Salutation/de.lobster.scm.base.address.Salutation) is selected as the Type, an error (Failed to create Instance) occurs at runtime.

NOTE

  • If a separate entity type is selected as the Type, then creating the instance for a new entity is equivalent to clicking 'New' in an interactive context (see Input forms or Custom overviews) and not to creating it by clicking 'Save'. However, the 'New' event (see Common (Events)) is not triggered.

  • In Event handling, a volatile entity can be marked for saving when the transaction is completed using the Execute with and Save changes later event actions. If required, the Fill primary key event action can also be executed in advance to obtain an ID for the entity from the server.

  • A Client workflow can create a volatile entity, e.g. to assign its data to a form element or embedded form via Populate element data. Even then, the volatile entity is persisted only if it is explicitly saved afterwards.

Configuration

images/download/attachments/201662370/image-2025-3-17_7-31-36-version-1-modificationdate-1742193095990-api-v2.png

For the single Type parameter, a selection field allows a static single selection for the class to be instantiated.

As can be seen in the screenshot, the search function takes into account the internal name in addition to the applicable localization for the language of the session, if any. Upper and lower case letters are ignored.

The [+] symbol indicates that class names not selectable in the dropdown can also be entered as free text.

Examples

Create and initialize a data object of the 'Date range with time' type

Within an event handling, a variable (enroute) specifies the expected transport time of a shipment as 'Date range with time' in the time zone that is selected as 'Default time zone' (defaultTimeZone) in the ordering party's company account.

The estimated transport time is given by two variables, which define the estimated time of departure (ETD) and the estimated time of arrival (ETA) of the transport as 'Date with time' (with any time zone).

Since a 'Date range with time' is not a simple value, but a 'complex' data object with several fields ('Time zone'/timeZone, 'From'/start and 'To'/end), an instance must be created as a target for the necessary value assignments.

The enroute variable is primarily intended to enable further calculations within the transaction. However, its value could also be assigned as a value to a date attribute of the shipment (e.g. 'Estimated transport time'/ENROUTE_ESTIMATE).

Configuration:

As all three fields of the ‘Date range with time’ are to receive assignments, the Set values event action is used as shown on the right to use the created instance as the Target host for all assignments.

  • In the value configuration for the Target host of the Set value event action, the Create instance value resolver is used to instantiate the type ‘Date range with time’ (DateRange).

  • The directly concatenated Store value as variable value resolver stores a reference to the created instance in the enroute variable. The variable therefore only refers to the new data object and does not preserve its current state as a snapshot. The reference in the variable enables access to the created instance beyond the context of the value assignments within the Set values event action.

  • Three assignments are configured within the Set values event action, which affect fields in the data model of the generated DateRange instance as Target values:

    • For the assignment to the 'Time zone' (timeZone) field, the company account of the client (here in the principalCompany Variable) is accessed, in which a time zone should be specified in the 'Default time zone' (defaultTimeZone) field. The field provides the time zone identifier as text (e.g. Europe/London or UTC), which is automatically converted into a TimeZone value in the context of the assignment.

      NOTE◄ By default, the specification of a 'Default time zone' in the company account is optional. It may be advisable to link the Object property value resolver with a Default value resolver that specifies the UTC time zone via static text, for example, in the event that the company account does not contain any information.

    • By definition, the assignments to the ‘From’ (start) and 'To' (end) fields refer to milliseconds since 1 January 1970 (UTC), so that the corresponding values can be taken directly from the ‘Date value’ (dateValue) field of the respective variable of the ‘Date with time’ (ETD/ETA) type. However, the ‘time zone’ (timeZone) specified in these variables is irrelevant for the assignment.

images/download/attachments/201662370/image-2025-3-17_7-33-47-version-1-modificationdate-1742193227159-api-v2.png

Create a 'Set' type and fill it with values

Administrators should be able to run an automated 'health check' for Users accounts under their responsibility, which checks a catalog of criteria for these Users and, if necessary, points out a qualitative 'action required' in the management of the accounts.

Each 'action required' is identified by a key text. Each key text should only be listed once in the message. References to the affected accounts are not part of the requirement.

Runtime example:

images/download/attachments/201662370/image-2025-3-14_12-54-34-version-1-modificationdate-1741953273475-api-v2.png

Configuration:

An event handling, which can be triggered via a Custom action event (HEALTH_CHECK) starting from the ribbon in the overview for Users, is configured as shown on the right:

  • A Search (Event action) first determines all Users relevant for the check and provides them as a list in a users variable.

  • The following Execute with event action defines a new instance of the 'Set' (java.util.Set) type as the reference object for the action part via the Object Resolver parameter.

  • In the action block, a For each loop event action is executed that iterates over the Users accounts in the users variable and checks a number of criteria. If an 'action required' is detected, the associated text key is added to the 'Set' Type if it does not already occur among the existing entries.

    NOTE◄ The 'Set' type automatically monitors the uniqueness of the contained entries. As shown below, the possibly redundant text keys can simply be passed via a Modify list a to the list for which the variable name issueTypes was set in the context of the loop.

  • After all Users accounts have been checked, the Show alert (Popup) event action will output the detected 'issues' as a string representation of the 'Set' type. The Message parameter refers to the reference object, i.e. the 'Set' type, via an Object property value resolver 'without a field'.

images/download/attachments/201662370/image-2025-3-17_7-40-9-version-1-modificationdate-1742193608691-api-v2.png

images/download/attachments/201662370/image-2025-3-17_7-41-39-version-1-modificationdate-1742193698777-api-v2.png

Create, initialize and save a new entity

Within the company hierarchy, Company accounts that relate to a specific Company type (e.g. ‘logistics centre’) should be assigned to a specific 'Group' (see Companies as groups) depending on the selection for the ‘Country’ (address.countryCode) address field.

  • For each Country that appears for the first time in the address of a relevant company, a new 'Group' – i.e. a company account with the Company meta type 'Group' (GROUP) – will be opened automatically.

  • Each company should be linked to the ‘Group’ that has been set up for the Country specified in the address via an assignment in the ‘Parent companies’ (parentCompanies) field.

Configuration:

The screenshot on the right shows the configuration for event hajundling that reacts to the Triggering events 'Change' and 'Create' (see Common action event).


The Validating rule is an AND junction of a series of rules (including Check type, Company type rule, Role rule), which will not be discussed in detail here. These rules are intended to ensure that the actions defined below are only executed if there is ‘something to do’ with regard to the group assignment for the changed or created company.


The Actions on passed rule will also only be presented here in a broad overview, as the Create instance event action only affects an optional process step:

  • At the beginning, a Search is carried out to identify the ‘Group’ matching the Country of the company. If this already exists, it is written to the countryGroup variable.

  • The following If then else event action checks whether there is a search result in the Variable countryGroup. If this is empty (see Is empty), an additional group must be created for the country. An Execute with event action summarises all the necessary steps for this. These are described in detail below. The newly created group is written to the Variable countryGroup, which has not received a value from the search.

  • Finally, the ‘ID’ of the group found or created (countryGroup) must be added to the list in the ‘Parent companies’ (parentCompanies) field, if this is required.

images/download/attachments/201662370/image-2025-3-17_8-9-36-version-1-modificationdate-1742195375499-api-v2.png

For the context of the Execute with shown on the right, the external reference object (the company account for the ‘logistics centre’) is written to the newCompany variable.

In the Object resolver, the Create instance resolver with the Type ‘Company account’ (CompanyAccount) is used, which defines the new ‘Group’ as a temporary reference object for the following action block:

  • The Save changes later event action causes the 'Company account' instance that has just been created to be flagged for the 'Group' to be saved at the end of the transaction. On the other hand, this action means that this instance is immediately assigned a unique ‘ID’ (id) (see also Fill primary key).

  • The Set values event action fulfils different tasks:

    • In the value configuration for the Target host, a Store value as variable resolver ensures that the company account for the new 'Group' is written to the Variable countryGroup. Irrespective of this, it also serves as a Target host for all assignments without any special provisions, provided this takes a given input value into account. In this specific case, all assignments relate to fields in the group.

    • The Source object is read from the Variable newCompany, which acts as an interface to the external reference object – i.e. the company account for the ‘logistics centre’.

    • The ‘Metatype’ (metaType) field is statically set to the Company meta type ‘Group’ (GROUP).

    • The ‘Country’ (countryCode) address field is transferred directly from the Source host to the Target host.

    • The 'Matchcode' (address.accMatchCode) and 'Name' (addressName) address fields are filled with a concatenated string, taking into account the Country assignment in the Source host.

images/download/attachments/201662370/image-2025-3-17_8-11-15-version-1-modificationdate-1742195475274-api-v2.png

Runtime example:

If a company account is created for the first time for a ‘logistics centre’ with reference to the Country ‘Italy’ (IT), the event handling creates a ‘group’, i.e. a company account with the Company meta type ‘Group’ (GROUP), the text 'GROUP_IT' as the Matchcode and the (possibly temporary) name ‘NEW COUNTRY GROUP: IT’. The account is automatically assigned to the ‘Logistics centre’ as the ‘Parent company’. By convention, the Matchcode should enable the group created for a Country to be recognised so that the automatically created ‘Group’ can be renamed as required.