Show context menu

Event action – Abstract

Purpose: Opens a context menu defined specifically for this purpose at the current mouse cursor position in the client to enable selection.

The Show context menu event action opens a context menu at the current mouse cursor position in the client – starting from a possibly specially generated 'list' of choices.

The user's selection can be processed with one of the following modes:

  • Either the selection is processed synchronously server-side. Then the event handling is interrupted until the user's selection provides a return object for the subsequent event actions. If a parameterizable waiting time (>0 seconds) elapses without any selection, the context menu closes automatically.

  • Alternatively, the selection is processed asynchronously and exclusively on the client-side. Then a Client workflow defines event actions that the client executes as soon as a return object is selected, while the server continues event handling immediately after the context menu is opened.

In both cases, the user can close the context menu by pressing the Esc key or an interaction in the surrounding window (such as a mouse click outside the context menu) without making a selection.

When closing without any selection, 'no value' ($null) is passed as a return object to the event actions to be executed. Therefore, these are always executed after closing the context menu, so that the special case 'no selection' should be intercepted e.g. by an If then else or Execute with event action or in the Client workflow by a suitable 'Validating rule'.

Configuration

images/download/attachments/201664161/image-2025-3-21_14-58-56-version-1-modificationdate-1742566262103-api-v2.png

Parameter

  • The value resolver for Root items must return a 'list' that can contain simple values or complex data items. A single element must also be formally passed as an element of a list to appear as the only option in the context menu.

  • The optional Label expression (see Calculation expression) is applied per list element to define the label of the context menu option. Here the complete list element is considered $input. The default entry {label}therefore refers to the value of the label field in a listed item. If the Label expression is empty, all items appear without a label.

  • The optional Children field parameter identifies a data field of the listed item, which can contain a list defining items of a submenu. The items listed in it are also visualized as menu items by means of Label expression and Icon expression. This concept can be applied in a cascading manner, i.e. for several nested menu levels. Menu items are only considered selectable if they do not contain any 'Children fields'.

  • The optional Icon expression (see Calculation expression) is applied per list element to define the path to an icon (see Working with image resources (Icons)). The complete list element is considered as $input. Therefore, the default {icon} entry refers to the value of the icon field in a listed item. If the Label expression is empty, all options will appear without an icon and the context menu will appear without an icon column.

  • The option Enable search defines, whether a search for context menu entries is available in the menu or not (default).


images/download/attachments/201664161/image-2025-3-21_14-59-44-version-1-modificationdate-1742566262100-api-v2.png

The other parameters concern the behaviour of the opened context menu with regard to the selection of an entry by the user. Depending on the selected Mode, different configuration options are offered here:

The default Mode is the option 'Receive Item', which opens the context menu synchronously.

  • The parameter Name of result variable defines through which variable the following event handlings can access the return object, as soon as the context menu (with or without selection) is closed. If the user selects a menu item from the context menu, then the associated list item (from the list defined by Root items) is considered a return object in its entirety.

  • The Wait time defines the duration of the waiting time (in seconds) until the context menu is automatically closed if the user does not make a selection or closes the context menu without making a selection. The default value here is 30 seconds. The minimum value is 1 second. The waiting time can be set to be 'very long' with high values but not defined as 'unlimited'.

images/download/attachments/201664161/image-2025-3-21_15-2-5-version-1-modificationdate-1742566262089-api-v2.png

Alternatively, the Mode can be changed to the 'Execute action on client' option, which opens the context menu asynchronously, so that event handling continues immediately without waiting for a selection in the open context menu.

The only Item click action available when selected is the 'Client workflow' option. By selecting this option, a Client workflow can be defined that the event handler passes to the client at runtime for execution when the context menu is closed. The following applies to the context of the client workflow:

  • The transferred input object is the return object of the context menu. If the user selects a menu item from the context menu, then the associated list item (from the list defined by Root items) is considered as the return object in its entirety. If the context menu is closed without selection, the return object 'no value' ($null) applies.

  • The asynchronously triggered Client workflow does not get access to variables defined in the context of event handling or to their contents. This also means that in the triggered Client workflow, there is normally no access to the input object from the calling context, unless it is contained in or identical to the return object.

NOTE◄ In conjunction with the Mode 'Execute action on client', the context menu remains open 'indefinitely' in principle.

images/download/attachments/201664161/image-2025-3-21_15-3-8-version-1-modificationdate-1742566262084-api-v2.png

Definition of entries for the context menu

Basically, any list can be used to create a context menu via the value explorer for Root items. Lobster Data Platform / Orchestration offers various possibilities to generate lists via value resolvers or to extract them from existing data sources. The following examples pick out selected techniques from an extensive solution space.

Based on the default values for the Label expression (label), Children field (children), and Icon expression (icon) parameters, a static definition for a context menu in JSON format might look like this:

[
{"label":"COMPASS","icon":"fa://fal-compass",
"children": [
{"label":"North","icon":"fa://fal-arrow-up"},
{"label":"East","icon":"fa://fal-arrow-right"},
{"label":"South","icon":"fa://fal-arrow-down"},
{"label":"West","icon":"fa://fal-arrow-left"}
]
},
{"label":"GPS","icon":"fa://fal-satellite"}
]

Using an JSON to object value resolver (see also the 'Examples' section below), a 'list' for the Root items parameter in a Show context menu event action can be created from the JSON structure shown on the left.

Runtime example: The context menu opens when you click on a button to specify the destination of a tour more or less precisely.

images/download/attachments/201664161/image-2025-3-21_14-57-54-version-1-modificationdate-1742566262105-api-v2.png

  • To organize items in the same level of a context menu, a horizontal line can be created by adding an element to the list at the position in question, specifying the field type with the value hline.
    NOTE◄ The horizontal line is not selectable as a menu entry.

  • An entry in the context menu appears disabled if the element in question has a field with the name disabled that is assigned the value true (as a Boolean value, not as text!).
    NOTE◄ A disabled entry with children fields shows the '>' symbol in the right margin, but does not expand the children field. So a disabled item may hide a complete branch of a menu tree.

Both possibilities are illustrated by the following adaptation for the above example:

[
{"label":"COMPASS","icon":"fa://fal-compass",
"children": [
{"label":"North","icon":"fa://fal-arrow-up"},
{"label":"South","icon":"fa://fal-arrow-down"},
{"type":"hline"},
{"label":"East","icon":"fa://fal-arrow-right"},
{"label":"West","icon":"fa://fal-arrow-left"}
]
},
{"label":"GPS","icon":"fa://fal-satellite","disabled":true}
]

images/download/attachments/201664161/image-2025-3-21_14-56-40-version-1-modificationdate-1742566262108-api-v2.png

  • The options under 'COMPASS' now appear divided by a horizontal line for North/South and East/West.

  • The GPS option not only appears 'inactive' (grey), but also cannot really be selected.

NOTE◄ For the sake of simplicity, the introductory example omits two aspects in the menu definition that may be important in practice: The menu entry labels define static texts without reference to the Localization, so that the menu appears identical in all languages. In addition, the selectable list items do not provide a field that is used exclusively to identify the selected item. The user's selection would therefore have to be identified by the label or icon in the return object, or a combination of both features. Changes to these features then also generate changes in the triggered event handlings. The first of the following examples shows a more appropriate solution for both aspects.

Examples

Professionalization of the introduction example

First, the following will show how the configuration for the introductory example can be implemented in more detail and in a more 'professional' way, which on one hand ensures a language-dependent labeling of the menu items and on the other an independent identification of the selection options.

Configuration:

First, the static text for the definition of Root items is adjusted as shown below on the left. Then the entries shown on the right are created in the Localization.

[
{"key":"COMPASS","icon":"fa://fal-compass",
"children": [
{"key":"N","icon":"fa://fal-arrow-up"},
{"key":"E","icon":"fa://fal-arrow-right"},
{"key":"S","icon":"fa://fal-arrow-down"},
{"key":"W","icon":"fa://fal-arrow-left"}
]
},
{"key":"GPS","icon":"fa://fal-satellite"}
]

Instead of labels, a unique field key is now provided, which at the same time ensures the unique identification and thus the starting point for a localization of the entries via the Localization (see right).

images/download/attachments/201664161/image-2025-3-21_14-54-4-version-1-modificationdate-1742566262111-api-v2.png

  • A separate Resource bundle is dedicated to the context menu (contextHeading), which is not mandatory but maintenance-friendly.

  • In the Resource name column, all values are displayed that appear in the JSON definition (left) as a value for the key field. These are provided here with translations for the languages German and English.

  • The abbreviation GPS does not need to be translated.

The implementation of the context menu within an event handler or in a Client workflow can be implemented on this basis as shown below:

  • The value for the Root items parameter is defined by first defining the JSON structure as a static text value (see Static values) and then passing it via concatenation to a value resolver of the JSON to object type (with default settings).

  • In the Label expression, the Localization is accessed via the syntax [Bundle, Resource, Default], where the key field determines both the 'Resource Name' (Resource) and the default value (Default), which causes, for example, the untranslated entry for GPS to be labeled as 'GPS'.

  • For all other parameters, the default values are retained here. The JSON text has been adjusted to the default values for the data field of the Children field and the Icon expression right from the start.

NOTE

  • In addition to the labels, you could also define the paths for the icons via localization entries to enable language-specific symbols.

  • Alternatively, you could create a single language entry that defines the JSON structure for the context menu as a whole for each language. If the same context menu should be opened in different contexts, this approach would be particularly maintenance-friendly, as it allows the menu structure to be managed centrally for all contexts.

images/download/attachments/201664161/image-2025-3-21_14-50-39-version-1-modificationdate-1742566262117-api-v2.png


Build context menu from the result of a tuple search

Requirement:

Within an input form, certain user accounts are to be offered for selection in a context menu in order to trigger the creation of an e-mail message to their address via the mailto protocol.

Detailed requirements:

  • When clicking on a Button, a context menu should be opened, which lists relevant users (with name and username) sorted alphabetically in ascending order and points to the 'language' selected for their user account via an icon.

  • Only users whose user account is set to 'Active' are selectable. 'Inactive' users are also listed, but are not selectable.

Runtime example:

images/download/attachments/201664161/image-2025-3-21_14-45-14-version-1-modificationdate-1742566262121-api-v2.png

Configuration:

The desired flow can be handled completely as a Client workflow in the following steps, e.g. in a behaviour for the button:

  • A Validating rule here is a Static rule (with the default value true), because the execution of the following actions should occur without any restrictive conditions.


  • The Search (Event action) defines a tuple search for the entity Users, which – as subsequently explained in more detail – in addition to the selection of everything relevant, also prepares certain user data for the display of the context menu.

  • The result of the search is passed by variable to the Show context menu event action, which lets the user select which contact person should be written to. There is no check whether the search action has returned any contact persons at all. The context menu may therefore appear empty.

  • To ensure that the e-mail client is addressed only if the user has selected one of the contact persons offered in the context menu, the following If then else event action checks whether the variable used for passing is empty.

images/download/attachments/201664161/image-2025-3-21_14-44-13-version-1-modificationdate-1742566262124-api-v2.png

Relevant configurations for each step of the client workflow are discussed below:

Search action

  • The Save result as parameter defines the name of the variable (here: users), which can be used to access its return value after the search action.

  • The Entity we are looking for in our example are Users.

  • Under Mode, the search value was selected so that all 'result rows' are returned directly as a list.

  • The Search is defined as a 'Tuple search', because on one hand access to complete user accounts is not necessary and on the other data should be prepared for the context menu by defining projections.


  • The fields 'Username' (username), 'ID' (id) and language (locale) are taken directly as a Property projection.

  • For the label in the context menu, the name fields from the user's address (adresse.name1/2/3) are concatenated by a literal space each via 'text concatenation projection'.

  • The field disabled, which is used in the context menu to control whether a contact person is selectable or not, is assigned a negation of the Boolean value from the field 'active' (active) in the user account:

images/download/attachments/201664161/image-2025-3-21_14-42-20-version-1-modificationdate-1742566262128-api-v2.png

images/download/attachments/201664161/image-2025-3-21_14-25-33-version-1-modificationdate-1742566262132-api-v2.png

The negation can only be displayed here via a Case projection, which can be configured with a few clicks.

For the context menu, it is important that the values assigned as Literal projection (true or false) are actually of the Boolean data type and not just text values with the same wording.

NOTE◄ Depending on the specific requirements, 'conditions' for the Search (Event action) may have to be specified, since otherwise all 'readable' user accounts will appear as contact persons. Details on this are omitted for lack of relevance with regard to the context menu.

Open context menu

The Search (Event action) stores all returned result rows as a list in the users variable, which can thus be used directly in the value explorer for the Root items for the context menu to be opened:

  • Although the desired alphabetical sorting by the label field would also be possible within the definition of the search, for demonstration purposes the result list shall be sorted afterwards by concatenating a Sort list value resolver which uses the label field as the Compare value.

  • The Label expression combines the label and username fields with some literal formatting.

  • A data field for the Children field is not specified.

  • The Icon expression takes advantage of the fact that the Lobster Data Platform / Orchestration default includes a collection of icons for national flags, whose filename matches the internal identifier for the selectable 'language' (locale) for many states. However, as the expression conveys, an exception had to be defined via the $replace function so that the icon for the flag of Great Britain (gb.png) appears when the language 'English' is selected.

  • The selected Mode is 'Receive Item', because the context menu should be opened synchronously and the calling Client workflow should be interrupted until it is closed or the Wait time for value return (30 seconds) expires.

  • The Name of result variable specifies that the element selected by the user is stored in the selectedUser variable.

images/download/attachments/201664161/image-2025-3-21_14-22-44-version-1-modificationdate-1742566262136-api-v2.png


Notify selected contact person...

After closing the context menu, a check should urgently be made whether a user has been selected or not. For this purpose, an If then else event action can be configured as shown to the right:

  • The only condition that is sufficient is an Entity property rule that checks whether the selectedUser variable is 'not-empty'.

  • In the Then block, the decisive Open external URL event action triggers the creation of an e-mail with the default mail client by building a URL via Concat strings that starts with the mailto: prefix for the protocol and then combines the username username with a static text for the domain name (@acme.org).

Runtime example:

images/download/attachments/201664161/image2021-3-26_18-2-24-version-1-modificationdate-1742566262312-api-v2.png

NOTE◄ The rigid structure used here for the e-mail address is of course only legitimate if all Users listed in the context menu can be reached via the same domain and that the mail address there always corresponds to their user name for Lobster Data Platform / Orchestration. In a real situation, a more elaborate logic for determining the e-mail address would certainly be appropriate, which could, for example, include further data from the user account.

images/download/attachments/201664161/image-2025-3-21_14-21-36-version-1-modificationdate-1742566262139-api-v2.png