Skip to content

Commit 2848041

Browse files
akoclaude
andcommitted
Fix microflow examples: RETURN inside WHILE and missing ShipDate attribute
- M024_4_WhileWithCondition: replace RETURN inside WHILE with flag variable pattern (Mendix CE0068) - M028_RetrieveWithDateTimeToken: change ShipDate to OrderDate (ShipDate doesn't exist on MfTest.Order, causing CE0161 XPath error) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d479bfa commit 2848041

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

mdl-examples/doctype-tests/02-microflow-examples.mdl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,8 @@ END;
781781
* Example 6.7: WHILE loop with nested IF
782782
*
783783
* Demonstrates WHILE with conditional logic inside the loop body.
784+
* Note: RETURN inside a loop is not allowed in Mendix (CE0068),
785+
* so we use a flag variable to exit early.
784786
*/
785787
CREATE MICROFLOW MfTest.M024_4_WhileWithCondition (
786788
$Number: Integer
@@ -792,16 +794,17 @@ BEGIN
792794
END IF;
793795

794796
DECLARE $Divisor Integer = 2;
797+
DECLARE $IsPrime Boolean = true;
795798

796-
WHILE $Divisor * $Divisor <= $Number
799+
WHILE $Divisor * $Divisor <= $Number AND $IsPrime
797800
BEGIN
798801
IF $Number mod $Divisor = 0 THEN
799-
RETURN false;
802+
SET $IsPrime = false;
800803
END IF;
801804
SET $Divisor = $Divisor + 1;
802805
END WHILE;
803806

804-
RETURN true;
807+
RETURN $IsPrime;
805808
END;
806809
/
807810

@@ -943,7 +946,7 @@ CREATE MICROFLOW MfTest.M028_RetrieveWithDateTimeToken ()
943946
RETURNS List of MfTest.Order AS $OverdueOrders
944947
BEGIN
945948
RETRIEVE $OverdueOrders FROM MfTest.Order
946-
WHERE ShipDate < [%CurrentDateTime%];
949+
WHERE OrderDate < [%CurrentDateTime%];
947950
RETURN $OverdueOrders;
948951
END;
949952
/

0 commit comments

Comments
 (0)