🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
Adding Actions and Relations in MDriven Agile MVC
This page was created by BSMaintenance on 2026-06-08. Last edited by BSMaintenance on 2026-06-08.
MDriven Agile MVC - is pretty fast


Enhancing an MDriven application by adding actions and establishing relationships between classes showcases the agility of the MDriven framework. This tutorial guides you through creating a new ticket action and linking users to tickets, enabling rapid development and iteration.

Adding a Create Ticket Action

To add a new action for creating tickets in your application, follow these steps:

  1. Open the action definitions in MDriven Designer.
  2. Create a new ViewModel action and name it Add Ticket.
  3. Set the action to be shown in the ticket search nesting.
  4. Configure the action to bring up the Ticket ViewModel with a root object of a new ticket.
  5. Run the application to verify that the new action appears in the ticket search window.

Once added, users can create new tickets by navigating to a window where they can enter ticket details.

Establishing a User-Ticket Relationship

To track which user creates each ticket, establish a relationship between the User and Ticket classes:

  1. In MDriven Designer, add a relation between User and Ticket.
  2. Name this relation Creator to indicate the user who creates the ticket.
  3. Update the generated code and database schema to reflect this new relationship.

Modify the ticket display to show the creator's name instead of the ticket ID. Use a view hint to display this information as static and non-editable.

Updating the Database Schema

After modifying the model, evolve the database schema to accommodate the new relationship:

  1. Instruct the MDriven Server to evolve the database schema.
  2. Check the status to ensure that the foreign key has been added to the ticket table, linking to the user who created the ticket.

Assigning the Creator in OCL

Automatically assign the creator when a ticket is created using Object Constraint Language (OCL):

  1. Amend the Add Ticket action to include OCL logic.
  2. Use a temporary variable T to hold the new ticket.
  3. Assign the Creator attribute of T to the current user using the oclSingleton operator.
  4. Return the ticket object for the ticket window.

Testing and Deployment

Test the application to ensure that the creator is correctly assigned and displayed:

  1. Log in and navigate to the ticket creation window.
  2. Create a new ticket and verify that the creator's name is automatically filled.
  3. Search for tickets to confirm that the new ticket appears with the correct creator information.

Finally, deploy the updated application to the MDriven Server, ensuring all changes are published and accessible.

For more insights into MDriven's capabilities, explore the Documentation:MDriven Turnkey Series and Documentation:Actions And Viewmodels, MDriven Designer.

Source

Based on the MDriven video MDriven Agile MVC - is pretty fast.