Create list

Value resolver – Abstract

Purpose: Creates a data object of the 'List' (java.util.List) type and returns it – optionally pre-populated with the entries defined via value resolvers.

images/download/attachments/78256018/image2022-8-5_18-42-36-version-1-modificationdate-1659717756526-api-v2.png

The Create list value resolver creates a data object of the 'List' (java.util.List) type and returns it.

The list can optionally be assigned values ($null, simple values or data objects) as entries.

The input value is not processed immediately, but is passed on to the value resolvers for list entries as an input value.

NOTE◄ To create a List object without entries, the Create instance value resolver (with the class 'List'/java.util.List) can also be used.

Configuration

For optional assignment of entries for the generated list, instances can be added to the configuration by clicking on the images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/add.svg icon and Resolvers can be defined in them. Existing entries can be removed by clicking on the images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/forbidden.svg icon.

  • Without entries (see screenshot above) the value resolver returns an 'empty list' (similar to the Create instance value resolver with the class 'List'/java.util.List).

images/download/attachments/78256018/image2022-8-5_18-43-3-version-1-modificationdate-1659717783538-api-v2.png

Result (in JSON notation):

{ "class": "list", "data": [ ] }

By default, each entry is assigned 'No value' ($null). However, this does create a list entry that contains the value $null:

images/download/attachments/78256018/image2022-8-8_9-49-56-version-1-modificationdate-1659944997227-api-v2.png

Result (in JSON notation):

{ "class": "list", "data": [ null ] }

NOTE◄ When clicking the images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/add.svg to add the first item, the read-only 'template' for entries (with gray border) is replaced by an active entry (with blue border) in the configuration user interface.

Examples

Assignment to an object property that expects a list

The 'Companies' assigned to a certain user account (for the selection of the Company of session at login) are assigned automatically via event handling. The list should refer to exactly two company accounts statically predefined in the configuration.

Configuration:

The user account in question is defined as a reference object in the configuration on the right by an Execute with event action (not shown in the image). The assignment is done by a Set value event action:

  • The Object property value resolver (left) defines the target property 'Companies' (companies) for the assignment.

    NOTE◄ As the reference to the data type below the property selection in the value resolver suggests, the property expects a list of Long values, i.e. in our context the IDs (id) of the repsective company accounts and not the complete company account as entity.

  • On the right, the Create list value resolver creates one with the IDs of two company accounts, each defined by the Company value value value resolver, from whose return value the 'ID' (id) of the account is resolved via the concatenated Object property value resolver in each case.

    NOTE◄ After predefining the ID values of the two companies, one could also achieve the same result by setting the IDs as static long values in the Create list value resolver. However, this should be avoided with regard to the exchange of configurations via Meta exchange (e.g. between test/production system), since this automatically 'recognizes' only company accounts identified via Company value value resolver.

images/download/attachments/78256018/image2022-8-5_18-44-45-version-1-modificationdate-1659717885523-api-v2.png

Provide statically defined values for an In list comparison

An association criterion is intended to assess whether the 'Zip code' (zipcode) address property locates the Company of session in one of several 'hand-picked' regions in a given country.

Configuration:

Within a With rule (not shown completely in the image), the reference object is the company address in the 'address' (address) property of the company account returned by the Company of session value resolver. In the context of this address, two AND-linked instances of the Entity property rule are configured:

  • The first Entity property rule ensures that the Company of session is located in the searched country (here: Germany).

  • The second Entity property rule checks whether the company is located in one of the searched postal code areas by means of the Zip code:

    • On the left, the Object property value resolver reads the ZIP code from the 'Zip code' (zipcode) property of the address. Using concatenation, the Substring value resolver extracts the first two digits from the postal code below, since only these digits are decisive for the check.

    • If the In list type is selected as Matchers, the Create list value resolver automatically appears on the right side as a suggestion. Here, the 'positive list' with the two-digit number combinations for relevant regions can be entered directly. An entry must be created for each region by clicking on the images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/add.svg symbol. After that the leading digits of the Zip code can be configured as static text (see Static values) as value.

NOTE◄ Instead of the Create list value resolver (right), the list could also be defined quite conveniently as static text in JSON notation (see below) and passed to a JSON to object value resolver via concatenation:

["80","86","90"]

images/download/attachments/78256018/image2022-8-5_18-46-21-version-1-modificationdate-1659717981501-api-v2.png

Provide list values for one iteration per For each loop

Using a For each loop, automatic information should be notified to stakeholders from the context of an entity as soon as it is deleted.

Specifically, the following stakeholders should be informed about the deletion of the entity:

  • The creator of the entity, i.e. the user referenced in the 'Creator' (creatorId) property.

  • If different from the creator: The user who last changed the entity according to the 'Last modified by' (lastModifierId) property.

  • The owner of the entity, i.e. the company referenced in the 'Owner' (ownerId) property.

It is assumed that the address (address) of the relevant accounts (Users/Company accounts) contains an e-mail address for notification.

Configuration:

Within an event handling that reacts to the event 'Delete' (see Common action event), the action part is configured as follows:

  • A For each loop iterates over a list of addresses and triggers a Custom action event 'Xf Mail Job' (XF_MAIL_JOB) for each address contained in the list (as input value).

    NOTE◄ Information about the deleted entity is provided to this event via the deletedEntity variable, which is filled in the loop header with the input value of the event handling shown here (i.e. the deleted entity).

  • In the Resolver for entities, the Create list value resolver is used, which creates a list with exactly three entities:

    • For the first entry, the creatorId property of the entity is read and the relevant user account is obtained via the Input object (type safe) value resolver.

    • The second entry accesses the server-side state of the entity to be deleted via the Original entity value resolver (see note below), reads its lastModifierId property, and then obtains the user account in question via the Input object (type safe) value resolver.

    • The third entry reads the ownerId property of the entity to be deleted and obtains the relevant company account via the Input object (type safe) value resolver.

    • The Collect values value resolver concatenated with the Create list value resolver extracts the address property from all list entries, using (not shown in the image) the 'Unique values' option so that a notification is not triggered multiple times for the same 'address' object.

images/download/attachments/78256018/image2022-8-5_18-48-6-version-1-modificationdate-1659718086077-api-v2.png

NOTE◄ The Original entity value resolver is important because the user responsible for deleting the entity is already referenced by lastModifierId in the context of the 'Delete' event. However, the user who last sent to the server via 'Save' for the entity is informed.