Show alert (Popup)

See also: Show alert, Abort

Event action – Abstract

Purpose: Displays a popup (as a notification or alert) with configurable content to the user in an interactive session:.

The Show alert (Popup) event action displays a configurable popup to the user in an interactive session, either as a notification (on the right edge of the screen) of a specific type, or as an alert (centered dialog with OK button to acknowledge the message).

NOTE◄ The Show alert action (in the context of Behaviours in forms) and the Abort can mimic alerts, although the type does not completely match by name. Functional details differ as well (see 'Configuration' below).

Configuration

images/download/attachments/177912202/image-2024-9-18_10-13-12-version-1-modificationdate-1726647192266-api-v2.png

'Type' parameter

The Type parameter defines the appearance of the popup at runtime and also has functional implications:

Type

Features

Example

Alert
(corresponds to an 'Alert box' in the Show alert and 'Semantic Exception' in the Abort)

A dialog appears, which can be closed by clicking the OK button or by clicking the 'x' symbol (top right).

NOTE

  • Alerts always appear centered with respect to the entire browser window and cannot be moved or resized by the user. They cover the client session with shading that blocks access to other interactive client features.

  • However, event handling does not stop until the user closes an alert displayed by Show alert (Popup), but continues to run in the background. If further alerts are opened during this process, they may appear 'stacked', so that the last one displayed must usually be acknowledged first.

  • The Close after (seconds) parameter does not apply to the 'Alert' type!


images/download/attachments/44935410/image2020-7-9_18-45-50-version-1-modificationdate-1594313153321-api-v2.png

Info

(Styles Properties strongBackgroundColor, strongBackgroundContrastColor,
successColor for the icon)

A notification appears (see illustrations on the right), which is displayed at the right edge of the browser window below previous notifications, if applicable.

NOTE

  • Notifications can be closed via the 'x' icon (top right).

  • The Close after (seconds) parameter in configuration determines the duration an alert is dsplayed and when it automatically disappears (setting: >0 seconds) or whether it should remain displayed 'indefinitely' (until interactive closing) (setting: 0 seconds).

  • The display duration or interactive closing of notifications has no influence on event handling, which is not paused but resumed immediately after a notification is displayed.

  • If many notifications are displayed at the same time, they may be displayed outside the visible display area so that the user does not see them at all, or only when they 'move up' because notifications displayed above are closed automatically or interactively.

The text and background colors can be defined for all popup types via the Styles properties given on the left, deviating from the standard shown on the right. However, it should be taken into account that customizations for the scope of the Styles apply globally (to all popupsof the type) and the same color values can also affect system-generated notifications and other functionalities (Abort, Show alert, Set hint, etc.) or color values directly or indirectly (via inheritance, see Styles).

images/download/attachments/44935410/image2020-7-9_18-41-8-version-1-modificationdate-1594312870641-api-v2.png

Error

(Styles Properties errorColor, errorContrastColor)

images/download/attachments/44935410/image2020-7-9_18-44-28-version-1-modificationdate-1594313071193-api-v2.png

Warn

(Styles Properties warnColor, warnContrastColor)

images/download/attachments/44935410/image2020-7-9_18-42-24-version-1-modificationdate-1594312946423-api-v2.png

Success

(Styles Properties warnColor, warnContrastColor)

images/download/attachments/177912202/image2020-7-9_18-41-47-version-1-modificationdate-1726646464220-api-v2.png

'Execute on commit' option

If the Execute on commit option is set differently from the default, then the relevant popup appears only if a 'commit' is made on the database at the end of the event processing (i.e. if necessary after processing a complete event chain). This is only the case if the event handling is triggered at all in the context of a transaction and runs without errors and without an Abort (i.e. without rollback).

IMPORTANT◄ In connection with the Execute on commit option, it is important to consider the following aspects:

  • A Custom action event does not automatically require a transactional context. Without this, popups for which the Execute on commit option is set will not be displayed.

  • Also, when running Tests for event handlers, the 'commit' is omitted, so popups do not appear for which the Execute on commit option is set.

  • The Resolvers for the content of Title and Message of a popup are only processed if the Execute at commit option is set. This means that the content of the message (if relevant) takes into account the data state of variables and objects that applies at the time of the commit, not the one at the time the Show alert (Popup) event action is executed. The only information 'held' at the time of the event action for later use is the current reference object (entity). However, only a reference is 'noted' and not a snapshot, so that Resolvers that refer to the reference object again 'resolve' the possibly deviating data status during the commit.

'Title' and 'Message' parameters

Strings are expected as values for the Title and Message parameters, which appear at different positions in the alert format depending on the Type (see above).

NOTE◄ For the Title parameter, the default value 'Title' appears if the string returned by the value resolver contains no characters or 'no value' (null) is returned.

If one of the used value resolvers returns a data type other than String at runtime, i.e. no string as return value, then an attempt is made to automatically convert the return value into a string:

  • A Boolean value is converted to the text value true or false, for example.

  • Instead of a complex data object for an entity e.g. of the Users type, a text value like 1901:de.lobster.scm.base.security.user.User@5ffd2762 appears.

  • If a list is returned, then each element is converted to a string and the strings of all elements appear separated by commas between square brackets. As the following expression illustrates, this concept also works recursively when a list value is in turn a list:

    [2021, is a good year for, [decisions, wine, Lobster]]
  • Instead of the localization for the value of a dynamic enumeration, its internal name (name) appears, e.g. CNE for the 'Consignee' Company type.
    NOTE◄ In the context of a form, Show alert automatically accesses the Localization or Company specific localization to consider localizable content in the title or message text. Show alert (Popup), on the other hand, always accesses the relevant internal name of a localizable content and takes localizations into account only if the value resolver Value from localization is used (see example).

'Close after (seconds)' parameter

The specification for the Close after (seconds) parameter only applies to notifications with a Type from the notification category, since the alert Type is not closed automatically..

With a value of 0 seconds, a notification is displayed indefinitely, that is, until the user uses the 'x' icon to close it.

Example

When triggering selected events for all objects of the 'Business transaction object' type, a notification of the notification type : Info should appear if a 'Super user limited' (role) is logged in.

The popup should remain open indefinitely and provide the 'Super user limited' with information about the type of object (in the Message) and the event triggered (in the Title), as seen in the following runtime example for the 'Delete' event for an order:

images/download/attachments/177912202/image2021-4-29_13-10-36-version-1-modificationdate-1726646464251-api-v2.png

Configuration:

An event handler is created and configured as shown to the right:

  • The Triggering events listed here are the standard events 'Create' and 'Delete' (see Common action event) and a Custom action event 'Xf Test'.

  • As a Validating rule, an AND conjunction is configured from a Check type on the type 'Business transaction object' and a Role rule that restricts the scope of the event handling to the role 'Super user limited'.

    NOTE◄ The Type 'Business transaction object' specified in the Check type is a parent type for all business objects (Shipments, Orders, Manifests, Common business object). Nevertheless, the message should indicate the specific type of the respective entity.

images/download/attachments/177912202/image2021-4-29_14-29-34-version-1-modificationdate-1726646464218-api-v2.png

The only Action on passed rule here is configured to be a Show alert (Popup) event action as shown to the right:

  • The Type 'Info' specifies the output of a notification with the respective appearance.

  • The Execute on commit option has been omitted here because the attempt to delete or create a business transaction object should already be displayed immediately. Otherwise, the custom action event 'Xf Test', which does not imply a transaction, would not trigger a message.

  • In the Title parameter, the Triggering event value resolver is used to indicate which triggering event has occurred.

  • The Message parameter refers to the entityClass variable, which is automatically assigned the class, i.e. the specific type of reference object, by the system.

  • The Close after (seconds) parameter is assigned the value 0 so that the notification display duration is unlimited.

images/download/attachments/177912202/image2021-4-29_14-30-23-version-1-modificationdate-1726646464215-api-v2.png

Variant:

Instead of the internal identifiers (name for the triggering event, class name for the business object type), the following configuration of the Show alert (Popup) event action is to display the corresponding texts from the Localization:

images/download/attachments/177912202/image2021-4-29_14-31-33-version-1-modificationdate-1726646464212-api-v2.png

The Show alert (Popup) event action is reconfigured within the existing event handling as shown to the right:

  • The Title is now defined by a value resolver of Value from localization type, which has as the class name de.lobster.scm.actionevent.CommonActionEvent
    (Common action event) as a Bundle and the return value of the previously used resolvers Triggering event as the Resource.

    NOTE◄ The suitable Bundle name could be determined in this case by 'backward search' in the localization, by filtering on the output name (name) 'DELETE' as resource name around then the most plausible bundle name to select.

images/download/attachments/177912202/image2021-4-29_14-33-0-version-1-modificationdate-1726646464197-api-v2.png

  • The Value from localization value resolver is also used for the Message. However, here the variable component is linked in the form of the variable entityClass in the Bundle parameter, while the static text $name is specified for the Resource.
    NOTE◄ This relies on the convention that the definition of each class in Lobster_pro is localized by a combination of bundle name = full class name and resource name = $name.

images/download/attachments/177912202/image2021-4-29_14-33-38-version-1-modificationdate-1726646464192-api-v2.png