Skip to content

No MDL syntax for 'retrieve by association' in microflows #199

@ako

Description

@ako

Problem

There is no MDL syntax for retrieving a list of objects by traversing an association from a context object. In Studio Pro this is the "Retrieve by Association" action in the toolbox, one of the most common microflow building blocks.

Reproduction

CREATE MICROFLOW Module.GetChildren (\$Parent: Module.Parent)
RETURNS List of Module.Child AS \$Children
BEGIN
  RETURN \$Parent/Module.Parent_Child;
END;
/

Parses, but `mx check` reports:
```
[error] [CE0117] "Error(s) in expression." at End event
```

Same for `LOOP`:

```sql
LOOP $c IN $Parent/Module.Parent_Child BEGIN
...
END LOOP;
```

And `DECLARE`:
```sql
DECLARE $Children List of Module.Child = $Parent/Module.Parent_Child;
```

All three fail at build time with the same generic "Error(s) in expression".

Root cause

`$var/Module.Assoc` in microflow expressions is not rendered as a valid Mendix expression at build time. Studio Pro represents this as a `Microflows$RetrieveByAssociationAction` — a dedicated action with a context variable and an association reference — not as an expression.

Suggested fix

Two approaches:

A. Accept association path as an expression sugar

Detect `$var/Module.Assoc` in `RETURN`, `LOOP`, and `DECLARE` value positions and emit a `Microflows$RetrieveAction` (association mode) activity that populates an intermediate variable, then use that variable in the downstream statement.

B. Add explicit syntax

A dedicated `RETRIEVE` statement makes the action explicit:

```sql
RETRIEVE $Children FROM $Parent OVER Module.Parent_Child;

-- Then use normally
LOOP $c IN $Children BEGIN ... END LOOP;
RETURN $Children;
```

Option B is simpler to implement and matches the pattern of other MDL microflow statements (verb-first, explicit outputs).

Why it matters

This is a Mendix-100-level pattern. Every data-driven microflow needs it. Without it, MDL users have to fall back to `RETRIEVE ... WHERE` XPath queries, which are less efficient and require the child entity's associations to be indexed / queryable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions