Triggering event

Value resolver – Abstract

Purpose: Identifies the event that triggered the execution of the current event handling at runtime.

images/download/attachments/177910558/image2022-7-19_12-15-10-version-1-modificationdate-1726035571715-api-v2.png

The Triggering event value resolver identifies the event that triggered the execution of the current event handling at runtime.

The return value is the triggering event (see Triggering events). The type of the return value is specified in the configuration as 'Interface > to action events', since triggering events of different types can occur at runtime. Basically, two categories of real events can be distinguished here:

  • Predefined events are assigned to different static enumerations depending on the category. Each static enumeration provides events of a specific type, e.g. 'Common'. (de.lobster.scm.actionevent.CommonActionEvent).

  • Custom action events are managed in the associated dynamic enumeration (Custom action event). The specific type of custom action event is always 'Custom action event'. (de.lobster.scm.actionevent.CustomActionEvent).

Specific value resolvers ('Any static enum' or 'Any dynamic enum', see Static values) define static values from the respective enumerations which can be compared in rules with the return value of the Triggering event value resolver.

As string mapping for an 'Event' returned by the Triggering event value resolver, the internal 'Name' (name) of the respective count value appears, e.g. 'CREATE' for the predefined event 'Create' from the category Common action event). This internal name can be sufficient information to inform about the triggering event in a Show alert (Popup) event action. However, using this name instead of the enumeration value in a rule that is supposed to uniquely identify the triggering event or match it against a list of comparison values is only partially recommended, since there is no mechanism to prevent an internal name from a static enumeration for predefined events from also being used as the name for a Custom action event. Therefore, the name does not necessarily uniquely identify the event unless there is an additional check type for the return value.

NOTE◄ In the course of Tests for Event handling, the triggering event can be explicitly selected (via the 'Action event' parameter). If the Triggering event value resolver is used within the event handling configuration, specific Tests can be defined for each relevant triggering event this way. As a default value for tests whose definition does not specify an 'Action event', the 'virtual' event TESTING (with de.lobster.scm.utils.testing.TestingManager$TestEvent type) is automatically created.

Configuration

The value resolver does not use any parameters and ignores the input value.

Examples

Localized notification of the triggering event

An event handler that can be triggered by events from different categories generates a notification indicating the localization for the triggering event for the Current locale.

  • The title of the message should indicate the specific type of the event by localization for the Current locale.

Runtime example:

Configuration:

In the action part of an event handling, the user is informed about the triggering event by a Show alert (Popup) event action.

As can be seen on the right, the Show alert (Popup) event action is placed inside an Execute with event action that uses the Triggering event value resolver in the Object Resolver.

On the one hand, this is useful because the 'Title' and the 'Message' are defined depending on the triggering event.

On the other hand – and this is particularly important here – the entityClass variable for the Execute with event action block is automatically assigned the name of the specific type of triggering event needed to retrieve the localizations in the Show alert (Popup) event action (see below).

images/download/attachments/177910558/image-2024-9-11_8-35-46-version-1-modificationdate-1726036546361-api-v2.png

The Show alert (Popup) event action must be configured as shown on the right to make the desired localizations (or default values, if applicable) appear in the notification:

  • The localized name for the type of triggering event should appear in the Title.

    • Due to the general convention for localization of types, this should be obtained under the Resource $name from the Bundle identified by the value of the entityClass variable within the Execute with event action.

    • The 'Entity class' (entityClass) should also be output as a Default value. It should only play a role for the default event in Tests (see above).

    • No specifications are required for a Parameter.

    • The locale is not defined, so localizations for the Current locale – if available – or the default language as a substitute, are accessed before falling back to the Default value.

  • Within the Message, the triggering event should be identified.

    • Due to the general convention for localizing enumeration values, the localization should be taken from the Bundle for the enumeration that identifies its 'Entity class' (in the entityClass variable).

    • The string mapping of the return value for the Triggering event is accessed as a Resource, which is the reference object for value resolvers in the Execute with action block. So the Input object (type safe) value resolver only ensures the conversion of the event as a string with its internal name.


    • For simplicity, the Default value here should use the same configuration as for the Resource and only output the internal event name, even if this is not necessarily unique without reference to the entityClass. While predefined events should be localized at least in the default languages (German and English), a Custom action event does not necessarily need to be localized. The default event for Tests (see above) is also not localized.

images/download/attachments/177910558/image-2024-9-11_8-43-16-version-1-modificationdate-1726036996406-api-v2.png images/download/attachments/177910558/image-2024-9-11_8-42-0-version-1-modificationdate-1726036920017-api-v2.png

Case differentiation depending on the triggering event

In the following example an event action E-Mail should be triggered, when certain events for a user data object (user account) occur if specific conditions are true:

  • A message is sent when a user account is 'Created' or 'Deleted'.

  • When a user is 'Updated' (precisely: changes are saved for an existing user account), a message should only be sent if the update is triggered by a session not referring to the 'Administrator' role.

images/download/attachments/177910558/image2019-5-13_10-29-52-version-1-modificationdate-1726035571736-api-v2.png

  • The event handler responds to the Triggering events 'Update', 'Delete' and 'Create'.

  • The Validating rule checks for the entity type 'User' by Check type.

  • Within the If then else action, the Triggering event resolver is used to determine if a 'Create' or' Delete' element triggered the event handler...

  • ... OR if the current session uses a role different from 'Administrator' (by a Role rule negated by the Not-option).

►NOTE◄ Provided that no further actions or conditions are added to the event handling, the check for the action event could also be integrated into the Validating rule in this example.