Skip to content

Commit 6c122cd

Browse files
engalarclaude
andcommitted
feat: ALTER WORKFLOW command with full activity manipulation
Add ALTER WORKFLOW support to modify existing workflows via MDL: - SET properties (Name, Description, AdminPage, ContextEntity) - INSERT/DROP/REPLACE activities (UserTask, Decision, ParallelSplit, etc.) - INSERT/DROP outcomes and paths on activities - SET conditions on decision outcomes - INSERT/DROP boundary events on user tasks - @n positional disambiguation for duplicate activity names - Version-gated to Mendix 9.12+ Includes grammar rules, AST nodes, visitor, executor with 22 unit tests, 17 visitor tests, and a 324-line doctype test example. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8ceb020 commit 6c122cd

25 files changed

Lines changed: 16179 additions & 11555 deletions

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ Full syntax tables for all MDL statements (microflows, pages, security, navigati
436436
- Database Connector generation from external schema (`SQL <alias> GENERATE CONNECTOR INTO <module>`)
437437
- EXECUTE DATABASE QUERY microflow action (static, dynamic SQL, parameterized, runtime connection override)
438438
- CREATE/DROP WORKFLOW with user tasks, decisions, parallel splits, and other activity types
439+
- ALTER WORKFLOW (SET properties, INSERT/DROP/REPLACE activities, outcomes, paths, conditions, boundary events)
439440
- CALCULATED BY microflow syntax for calculated attributes
440441
- Image collections (SHOW/DESCRIBE/CREATE/DROP)
441442
- OData contract browsing (SHOW/DESCRIBE CONTRACT ENTITIES/ACTIONS FROM cached $metadata)

docs/01-project/MDL_QUICK_REFERENCE.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,76 @@ BEGIN
264264
END WORKFLOW;
265265
```
266266

267+
## ALTER WORKFLOW
268+
269+
Modify an existing workflow's properties, activities, outcomes, paths, conditions, and boundary events without full replacement.
270+
271+
| Operation | Syntax | Notes |
272+
|-----------|--------|-------|
273+
| Set display name | `SET DISPLAY 'name'` | Workflow-level display name |
274+
| Set description | `SET DESCRIPTION 'text'` | Workflow-level description |
275+
| Set export level | `SET EXPORT LEVEL API\|Hidden` | Visibility level |
276+
| Set due date | `SET DUE DATE 'expr'` | Workflow-level due date expression |
277+
| Set overview page | `SET OVERVIEW PAGE Module.Page` | Workflow overview page |
278+
| Set parameter | `SET PARAMETER $Var: Module.Entity` | Workflow context parameter |
279+
| Set activity page | `SET ACTIVITY name PAGE Module.Page` | Change user task page |
280+
| Set activity description | `SET ACTIVITY name DESCRIPTION 'text'` | Activity description |
281+
| Set activity targeting | `SET ACTIVITY name TARGETING MICROFLOW Module.MF` | Target user assignment |
282+
| Set activity XPath | `SET ACTIVITY name TARGETING XPATH '[expr]'` | XPath targeting |
283+
| Set activity due date | `SET ACTIVITY name DUE DATE 'expr'` | Activity-level due date |
284+
| Insert activity | `INSERT AFTER name CALL MICROFLOW Module.MF` | Insert after named activity |
285+
| Drop activity | `DROP ACTIVITY name` | Remove activity by name |
286+
| Replace activity | `REPLACE ACTIVITY name WITH activity` | Replace activity in-place |
287+
| Insert outcome | `INSERT OUTCOME 'name' ON activity { body }` | Add outcome to user task/decision |
288+
| Drop outcome | `DROP OUTCOME 'name' ON activity` | Remove outcome |
289+
| Insert path | `INSERT PATH ON activity { body }` | Add path to parallel split |
290+
| Drop path | `DROP PATH 'name' ON activity` | Remove parallel split path |
291+
| Insert condition | `INSERT CONDITION 'name' ON activity { body }` | Add decision branch |
292+
| Drop condition | `DROP CONDITION 'name' ON activity` | Remove decision branch |
293+
| Insert boundary event | `INSERT BOUNDARY EVENT ON activity INTERRUPTING TIMER ['expr'] { body }` | Add boundary timer |
294+
| Drop boundary event | `DROP BOUNDARY EVENT ON activity` | Remove boundary event |
295+
296+
**Activity references** can be identifiers (`ReviewOrder`) or string literals (`'Review the order'`). Use `@N` suffix for positional disambiguation when multiple activities share a name (e.g., `ACT_Process@2`).
297+
298+
**Multiple actions** can be combined in a single ALTER statement.
299+
300+
**Example:**
301+
```sql
302+
-- Set workflow-level properties
303+
ALTER WORKFLOW Module.OrderApproval
304+
SET DISPLAY 'Updated Order Approval'
305+
SET DESCRIPTION 'Updated description';
306+
307+
-- Modify an activity
308+
ALTER WORKFLOW Module.OrderApproval
309+
SET ACTIVITY ReviewOrder PAGE Module.AlternatePage;
310+
311+
-- Insert and drop activities
312+
ALTER WORKFLOW Module.OrderApproval
313+
INSERT AFTER ReviewOrder CALL MICROFLOW Module.ACT_Escalate;
314+
ALTER WORKFLOW Module.OrderApproval
315+
DROP ACTIVITY ACT_Notify@1;
316+
317+
-- Manage outcomes on a user task
318+
ALTER WORKFLOW Module.OrderApproval
319+
INSERT OUTCOME 'Escalate' ON ReviewOrder {
320+
CALL MICROFLOW Module.ACT_Review;
321+
};
322+
ALTER WORKFLOW Module.OrderApproval
323+
DROP OUTCOME 'Hold' ON ReviewOrder;
324+
325+
-- Boundary events
326+
ALTER WORKFLOW Module.OrderApproval
327+
INSERT BOUNDARY EVENT ON ReviewOrder INTERRUPTING TIMER 'addHours([%CurrentDateTime%], 2)' {
328+
CALL MICROFLOW Module.ACT_BoundaryHandler;
329+
JUMP TO ReviewOrder;
330+
};
331+
ALTER WORKFLOW Module.OrderApproval
332+
DROP BOUNDARY EVENT ON ReviewOrder;
333+
```
334+
335+
**Tip:** Run `DESCRIBE WORKFLOW Module.Name` first to see activity names.
336+
267337
## Project Structure
268338

269339
| Statement | Syntax | Notes |

0 commit comments

Comments
 (0)