Skip to content

Latest commit

 

History

History
73 lines (57 loc) · 1.41 KB

File metadata and controls

73 lines (57 loc) · 1.41 KB

Microflow Logic

This tutorial shows how to create microflows -- the visual programming blocks that implement business logic in Mendix.

Prerequisites

Run scripts/02-create-entity.mdl first to create the Task entity.

Create a Simple Microflow

A datasource microflow that retrieves data:

mxcli -p App.mpr -c "
/**
 * Retrieve all tasks
 * @returns All tasks sorted by title
 */
CREATE MICROFLOW MyFirstModule.DS_GetAllTasks ()
RETURNS List of MyFirstModule.Task AS \$Tasks
BEGIN
    RETRIEVE \$Tasks FROM MyFirstModule.Task
        SORT BY MyFirstModule.Task.Title ASC;
    RETURN \$Tasks;
END;
/
"

Create a Microflow with Parameters

A microflow that takes input and modifies data:

mxcli -p App.mpr -c "
/**
 * Mark a task as completed
 * @param \$Task The task to complete
 * @returns true on success
 */
CREATE MICROFLOW MyFirstModule.ACT_CompleteTask (
    \$Task: MyFirstModule.Task
)
RETURNS Boolean AS \$Result
BEGIN
    CHANGE \$Task (
        Status = MyFirstModule.TaskStatus.Done,
        Completed = true
    );
    COMMIT \$Task;
    RETURN true;
END;
/
"

Describe a Microflow

See the MDL definition of any microflow:

mxcli -p App.mpr -c "DESCRIBE MICROFLOW MyFirstModule.DS_GetAllTasks"

Run the Full Example

mxcli exec scripts/03-create-microflow.mdl -p App.mpr

Next Steps