See also: Value changed (Compare type)
Value resolver – Abstract
Purpose: Returns the server-side (persisted) data state of the entity in the input value, if it exists.
Tooltip
Usage: The value resolver returns the server-side data state of an entity present as an input value, if it exists. This original entity can be used, for example, for comparisons with a deviating volatile entity state.
Note:
If the input value is not entity data, the input value is returned.
If the entity in the input value does not exist because it has not been saved yet, then the return value is $null.
Warning: Although the Original entity value resolver can be selected in a Client workflow, it is effectively useless because it always returns only the volatile state of the entity in the input value and not the 'original' value that is only available on the server side.
The Original entity resolver returns the server-side (persisted) data state of the entity in the input value, if it exists.
If the input value is data of an entity according to its type, but the entity is not yet created, then 'No value' ($null) is returned.
If the input value is not an entity according to its type, then the input value is returned.
Access to the original entity enables matching between server-stored data of an entity and a volatile, 'edited' state.
►NOTE◄ In principle, the Original entity value resolver can also be used for 'non independent' entities such as attributes. However, in practice it is usually more useful to compare attributes starting from the attribute owner (and its original entity). This is demonstrated by the second example below (More complex use case:').
►WARNING◄ Although the Original entity value resolver can be selected in a Client workflow, it is effectively useless because it always returns only the volatile state of the entity in the input value and not the 'original' value that is only available on the server side.
►IMPORTANT◄ Effect of lazy loading on entity and original object
In general, the lazy loading principle applies in the server context (e.g. when processing Association criteria or Event handling) for data that has a (1:n) relationship to an entity and is therefore handled in the entity's data object via list fields.
What is lazy loading?
Regardless of whether an entity is present as an input value or is included in the execution context through an Input object (type safe) resolver, the existing inventory for data stored in list fields will only be retrieved from the Lobster Data Platform / Orchestration database if needed.
Changes to the 'list data' of an entity that are caused outside the given execution context and persisted before the lazily executed retrieval may potentially be applied 'retroactively' to the execution context.
The data state in the execution context may therefore contain combinations of header and detail data that have never been or will never be persisted in the database in this form.
In this context, a 'need' refers to any access to the respective list field for the entity or the associated Original entity, provided that the data has not already been retrieved.
The following specific examples illustrate the principle:
A read access to the number of entries in the list of all attributes (attributes.length) of the entity leads to the retrieval of all attributes of the entity from the database, if they are not already present in the execution context.
Any direct or indirect access to line item list field entries – e.g. via Modify list event action, the List item value resolver, or the Direct line items value resolver – triggers retrieval of the entity's entire line item hierarchy.
►NOTE◄ When retrieving line items for an entity, its attributes (attributes) are automatically 'supplied' as an exception. Therefore, no lazy loading takes place at this level..
What does lazy loading mean for the Original entity value resolver?
For 'list data' (e.g. attributes or line items) of an entity, the Original entity value resolver returns the data state that the database provided via lazy loading at the time of the first demand in the execution context.
If the 'list' in question has not been loaded before in the execution context, a list access for the Original entity may also trigger joint lazy loading for the entity's list and the Original entity.
As long as list data is not modified during execution, a read access to list data for the Original entity always returns the same data as a direct access to the entity's data in the execution context cache.
CAUTION
Under certain circumstances, the Original entity for lazy loaded list data does not necessarily reflect the database state that existed when the execution was started or the entity was added to the execution context as an Input object (type safe), but possibly a different state stored outside the execution context at the time of lazy loading.
The following specific runtime scenario illustrates the relationship:
Event handling (see Event handling) 'fetches' an entity of the 'Order' type (see Orders) from an ID (id) given as a Long value via the Input object (type safe) value resolver into the execution context.
Immediately afterwards, a User callback event action requests a yes/no decision from the user to execute an optional process step (here: step 4).
While the user is still considering, another user changes an attribute of the order in question via an input form – e.g. by setting the value of a user-defined indicator attribute (see Flag type) 'Priority' – and saves the order.
In the process step requiring approval, some indicator attributes of the purchase order (including the 'Priority' indicator) must be evaluated in the context of a case differentiation per If then else event action.
The first read access to any attribute retrieves all attributes of the order from the database.
In this example, the 'Priority' flag is considered to be set, even if it would have been 'not set' (or not present) at the start of event handling.
If other attributes were changed in the 'foreign' session, these are also 'attributed' to the entity on-the-fly in the execution context.
►NOTE◄
If the evaluation logic checks whether the value of the 'Priority' indicator has been changed compared to the Original entity via an Entity property rule, this will not display any changes in the scenario described. The data status for the attributes retrieved after the User callback is mapped directly after the retrieval to the order and the associated Original entity, so that only subsequent changes to this status are detected for attributes.
If, on the other hand, a read access to any attribute of the order or even number of attributes (attributes.length) would be executed at the beginning of the event handling, the retrieval of the attribute data from the database already takes place at this time. Then the "priority" flag for order and Original entity is considered 'not set' (or not present) and a change in a 'foreign' session (see step 3) is not considered in the execution context because the attributes of an entity are retrieved only once.
Saving the order within the event handling (e.g. Save changes later) becomes impossible in any case due to the write conflict with the update persisted in step 3.
Configuration
The value resolver expects an entity as input value' and does not use any parameters.
Examples
Simple use case: Check a specific value change for a field
An association criterion (see Association criteria) determines whether the volatile data in the context of a shipment (see Shipments) contains a lower 'Number of packages' (numberOfPackages) for this entity than the number (last) stored on the server.
Configuration:
The association criteria first determines whether the data context provides a shipment as an input value via Check type.
If this is the case, the AND conjunction Entity property rule is evaluated:
On the left side of the comparison (see Compare with (Form designer)) the value for the 'Number of packages' (numberOfPackages) field is read in the volatile data of the shipment.
On the right side, the server-side state of the shipment is first obtained via the Original entity value resolver. The 'Number of packages' (numberOfPackages) field is then accessed via concatenation (as on the left).
The '< (smaller)' comparison causes 'Rule passed' to apply to the association criteria as a whole if the 'Number of packages' for the volatile state of the shipment is less than stored on the server side.
|
|
►NOTE◄ The evaluation of this association criteria only makes sense in a context in which a volatile state of the respective shipment can exist. It could be evaluated e.g. as a Sub criterion rule in the validating rule of an event handling which reacts to the 'Update' event (see Common action event) and contains actions which are only relevant if the 'Number of packages' of a shipment was reduced in the course of an update of the shipment data triggered via the interface or interactively.
More complex use case: Checking whether (singular) reference attributes differ
An association criterion (see Association criteria) is intended to determine in the context of a shipment (see Shipments) whether the reference values specified in reference attributes have changed from the server-side state.
Configuration:
The task requires pairwise checking of reference values in reference attributes with the same Reference type between the volatile data state and the associated original entity representing the server-side state.
For convenience purposes, the following configuration makes the following simplifying assumptions:
All reference attributes used in the context of Shipments are defined as non-plural (='singular') in the Reference type. For each Reference type there is exactly one or no reference attribute in the shipment data.
In the volatile state of the shipment, no reference attributes have been removed compared to the server-side state, so that every Reference type represented by a reference attribute on the server side is also present in the volatile state (with an empty reference value '' if applicable).
Under these conditions, the criterion in the sense of the task can be formulated as follows: 'The rule in the association criteria is passed if the volatile state of the shipment contains at least one reference attribute whose value differs from the value of the reference attribute corresponding to the Reference type in the state stored on the server side'.
The following configuration implements this logic.
The Store value as variable value resolver stores a reference to the volatile state of the shipment in the shipment variable so that it can be accessed within the criterion in the Rule list resolver below.
The concatenated All attributes of one type value resolver provides the list of all reference attributes in the volatile shipment data, i.e. the basis for pairwise matching of reference values.
The concatenated Rule list resolver uses an Entity property rule, for pairwise matching of reference values:
On the left side of the comparison, a Store value as variable value resolver is first used to store a reference to the currently relevant reference attribute in the attribute variable. This is needed so that the 'inner' Rule list resolver, which determines the comparison value on the right side, can refer to the Reference type of this attribute. The 'reference' (reference) field of this attribute is then accessed, providing the 'volatile' level for the reference value to be checked.
On the right side, the shipment variable is accessed at the beginning so that the concatenated Original entity value resolver can obtain the original entity, i.e. the server-side state of the shipment.
Below, an All attributes of one type first resolves all reference attributes in the server-side state of the shipment.
The concatenated Rule list resolver returns the reference attribute from this list that 'matches' the left page and corresponds to the Reference type (if available). Details about this are shown below.
The concatenated Object property value resolver accesses the 'reference' (reference) field in the reference attribute assigned for pairwise comparison from the original entity.
The negated Equals matcher in the Rule list resolver, in conjunction with the unchecked Resolve all as list option, defines that the search returns the first match 'with any difference' or 'no value' (if no differences were found).
The negated Is empty matcher of the outer Entity property rule defines that the rule is considered passed if the Rule list resolver found any difference in the reference values during pairwise matching.
|
|
The image on the right shows the right side from the Entity property rule in the outer Rule list resolver from the previous view. Here, the configuration for the inner Rule list resolver is expanded to reveal details of the contained Entity property rule:
On the left side of the Entity property rule, the 'Type' (referenceType) field is accessed, which specifies the Reference type of the server-side reference attribute to be matched with the Reference type from the outer Rule list resolver.
On the right side of the Entity property rule, the attribute variable is used to access the 'current' reference attribute in the outer Rule list resolver and – via concatenation – its 'Type' field.
Since the Resolve all as list option is unchecked, the Rule list resolver returns the first match for a server-side reference attribute whose Reference type matches the type of the reference attribute referenced in the attribute variable from the volatile shipment data – if this Reference type is already known on the server side.
►NOTE◄ Provided that shipments can use at least one plural Reference type , this has the potential to significantly complicate the matching process. In the context of an AND conjunction, in addition to the 'Type', the 'Index' field could also be matched, which defines the ranking of the attribute instances for plural reference attributes. However, it may not be appropriate for a pairwise comparison to include an index position. The reference values for a plural reference attribute may have to be matched without regard to the order of the attribute instances.. This would require a special evaluation for each relevant plural reference attribute. Its instances would then have to be excluded from the pairwise comparison via additional Rule list resolver (for the return value of the All attributes of one type resolver), for example by requiring that the index field be empty.
|
|