🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
Assign actions a menu group based on class
This page was created by Lars.olofsson on 2024-05-01. Last edited by Wikiadmin on 2026-07-29.

You can use an OCL query and an EAL update to assign one existing menu group to the class actions on every class that inherits from a chosen class.

This is useful when a superclass defines a family of types—for example, PeWork and its subclasses—and the class actions for that family must appear under the same menu group. This page changes the MenuGroup assignment only; configure menu hierarchy, dividers, and ordering in Documentation:Action menu groups.

Before you start

Make sure that:

  • The superclass or class you want to target exists in the model.
  • The destination menu group already exists.
  • You understand that this targets class actions, not global actions or ViewModel actions.
  • You run the inspection query and review its result before running the EAL update.

A class action is type-specific: it belongs to a class and is available where that class is known in the user interface. For an overview of action types and execution, see Documentation:Actions.

How the selection works

The expressions select every Class for which AllSuperClassesAndSelf includes the named target class. The selected set therefore contains:

  • The target class itself.
  • Every class that inherits from that target class, including through more than one inheritance level.

For example, if PeWork is the target, the expressions process PeWork and every class below it in the inheritance hierarchy. Classes outside that hierarchy are not selected.

1. Inspect the current class-action menu groups

Run this OCL expression first:

Class.allInstances->select(c|c.AllSuperClassesAndSelf->includes(Class.allInstances->select(c|c.Name='PeWork')->first)).ClassActions->collect(ca|ca.Name, ca.MenuGroup.Name)

The result lists the name of each selected class action and the name of its current menu group.

Replace PeWork with the exact name of the class or superclass whose hierarchy you want to process.

Example

If your model has PeWork as a common superclass, run the expression unchanged to review the actions before moving them. Review the returned action names and menu-group names. If actions outside the intended functional area appear, do not run the update until you have corrected the target class name or the model structure.

2. Assign the destination menu group

After you have reviewed the inspection result, run this EAL expression:

Class.allInstances->select(c|c.AllSuperClassesAndSelf->includes(Class.allInstances->select(c|c.Name='PeWork')->first)).ClassActions->forEach(ca|ca.MenuGroup := MenuGroup.allInstances->select(mg|mg.Name='PE')->first)

Replace the values as follows:

Replace With Example
PeWork The exact name of the class or superclass that defines the hierarchy to process. PeWork
PE The exact name of an existing destination menu group. Views/Special

The expression iterates over the class actions on every selected class and assigns the same existing MenuGroup to each action.

Verify the result

  1. Run the inspection OCL from step 1 again.
  2. Confirm that the returned actions now show the intended menu-group name.
  3. Check the rendered menu in MDriven Designer and, where applicable, your running application.
  4. If the actions need a particular order or visual section, set their divider group and sort order as described in Documentation:Action menu groups.

A menu group can contain submenus. For example, assigning an action to Views/Special places it under the Views menu and then its Special submenu. The menu-group sort key controls menu-group ordering; an action's sort order within its group controls ordering among actions in that group.

Scope and limitations

  • This update affects the menu-group assignment for the selected class actions. It does not create a menu group.
  • The destination menu group must already exist and must be identified by the name used in the expression.
  • Class actions are type-specific. If you need to organize actions in the application-wide menu, use global actions instead. See Documentation:Actions.
  • Menu placement does not determine whether an action is available to a user. Use access groups when you need audience-specific access control.
  • Whether and where class actions are shown also depends on their type context and action opt-in or opt-out settings. See Opting out actions.

See also