🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
MDrivenStart ClassActions
This page was created by Hans.karlsen on 2020-07-10. Last edited by Wikiadmin on 2026-07-29.

You use class actions to let users act on the currently selected instance of a class wherever that class is shown in the user interface.

What a class action does

A class action is an action defined for one class. When the user selects an object of that class, the action becomes available in the user interface, including the left-side menu.

The class type determines where the action is available. You do not need to identify every individual view where it should appear.

For example, if you define an action for the Order class, a user can use that action when they select an Order object. The same action is not intended for an object of an unrelated class, such as Customer.

When to use a class action

Choose a class action when the operation acts on one object instance and users should be able to perform that operation whenever they encounter an instance of that type.

A useful rule is:

  • Use a class action when the action is about the selected object.
  • Use a global action when the action belongs in the main menu and is not rooted in a selected object.
  • Use a ViewModel action when the action belongs to one specific view rather than to every instance of a class.

For example, an action that works with one selected Order is a class action. An action that opens a browser for finding orders is a global action. An action that applies only to the current view's focus or selected grid rows is a ViewModel action.

Availability follows the class

Class actions are practical because their availability is inferred from the model type. Defining an action on a class makes the action relevant whenever an instance of that class is selected, rather than requiring you to add the action separately to each place where the class can be displayed.

This model-based behavior also makes the intended scope clear: the action is for an object of the class on which you define it.

Opt out when the general rule has exceptions

The normal expectation is that a class action is available for every selected instance of its class. If that is not appropriate in a particular situation, opt out of the action for that exception.

For example, an Order action may generally be relevant for orders, but a specific user-interface context may need to exclude it. Treat this as an exception to the class-wide rule, not as the primary way to decide where a class action appears.

Related model work

Class actions operate on the information represented by a class. Define the class and its information first, including any relevant associations. If the action needs behavior that changes data, review methods and their action-language bodies. Validate the model before running or deploying it; see Verify.

See also