Now inviting automation leaders: publish your playbook as a skill, under your own name. Publish yours →
Automation Skills
All skills/Uipath core/Xaml-control-flow
Reference · Uipath core

Xaml-control-flow

Part of Uipath core. Install the skill and your agent reads this page when it needs the depth.

Control Flow Activities

If, IfElseIf, ForEach, ForEachRow, While, DoWhile, Break/Continue, ForEachFile, Flowchart, State Machine, annotations.

Contents

If

→ Use gen_if() — generates correct XAML deterministically.

If Else If (IfElseIfV2)

Multi-branch conditional — equivalent to ElseIf chains. Uses BindingList for additional branches. → Use gen_if_else_if() — generates correct XAML deterministically.

Notes:

⚠️ WRONG property names (common hallucination — Studio crashes):

Pick / PickBranch (Parallel Race)

Pick runs multiple PickBranch triggers in parallel — the first trigger that fires wins, its Action body executes, and all other branches are cancelled. Primary use case: login validation (race between "success element appears" and "error element appears").

⚠️ MANDATORY for Launch workflows with login. Every Launch workflow that performs login MUST use Pick to validate the outcome. See golden sample WebAppName_Launch.xaml for complete XAML.

→ Use gen_pick_login_validation() — generates correct XAML deterministically.

Key patterns:

For Each

→ Use gen_foreach() — generates correct XAML deterministically. For DataTable iteration, use gen_foreach_row() instead.

For Each Row in DataTable

→ Use gen_foreach_row() — generates correct XAML deterministically. Handles ActivityAction wrapper, DelegateInArgument, sd:DataRow TypeArguments.

While

→ Use gen_while() — generates correct XAML deterministically.

Do While

→ Use gen_do_while() — generates correct XAML deterministically.

Break & Continue (Loop Control)

→ Use gen_break() and gen_continue() — generates correct XAML deterministically.

Notes:

Annotations

Add sap2010:Annotation.AnnotationText="..." attribute on any activity element. Set IsAnnotationDocked ViewState key to True (attached) or False (floating). Annotations are design-time metadata — the generators don't produce them, but they can be added manually to generated XAML if needed.

For Each File in Folder (ForEachFileX)

Iterates over files in a directory. Uses two delegate arguments: CurrentFile (System.IO.FileInfo) and CurrentIndex (Int32).

→ Use gen_foreach_file() — generates correct XAML deterministically.

Key differences from ForEachRow:

Notes:

Real-world example — Switch on DataRow column value with case bodies updating Data Service entity: → Use gen_switch() — generates correct XAML deterministically.

Pattern notes:

Flowchart (alternative to Sequence-based workflows)

→ Use gen_flowchart() — generates correct XAML deterministically.

Critical Flowchart rules:

State Machine

Used by REFramework Main.xaml. States contain Entry actions and Transitions with conditions that route to other states. The XAML structure is deeply nested — gen_state_machine() handles all of it: inline state definitions, x:Reference back-references, ViewState, and av: namespace.

{
  "gen": "state_machine",
  "args": {
    "states": [
      {
        "ref": "S0", "display_name": "State A",
        "entry_content": "<!-- entry activities -->",
        "transitions": [
          {"to_ref": "S1", "display_name": "Go to B", "condition": "boolCondition"},
          {"to_ref": "S2", "display_name": "Go to Final (no condition)"}
        ]
      },
      {
        "ref": "S1", "display_name": "State B",
        "transitions": [
          {"to_ref": "S0", "display_name": "Back to A", "condition": "otherCondition"},
          {"to_ref": "S2", "display_name": "Go to Final"}
        ]
      },
      {"ref": "S2", "display_name": "End", "is_final": true}
    ],
    "initial_state_ref": "S0"
  }
}

Critical structural rules:

  1. InitialState="{x:Reference __ReferenceID_N}" — points to the starting state's x:Name
  2. First reference defines inline, subsequent references use <x:Reference>: Each State is defined in full XML exactly once — inside the first Transition.To that targets it. All other transitions to that state use <x:Reference>__ReferenceID_N</x:Reference>
  3. Final state: REFramework uses IsFinal="True" on a regular <State> element. Studio also supports a standalone <FinalState> element (only has Entry, no Exit or Transitions). Both are valid. Final states have State.Entry but no State.Transitions
  4. All back-referenced states listed at StateMachine level: After the first inline State, all other states appear as <x:Reference> elements directly inside StateMachine (before .Variables)
  5. Transitions are ordered: First matching condition wins. Omit Transition.Condition for the default/fallback transition (should be last)

ViewState keys specific to StateMachine/State:

State child elements:

Transition child elements (order varies in exports):

FinalState variants:

REFramework State Machine structure (4 states):

Initialization ──[Success]──> Get Transaction Data
    ^                              |
    |                    [New Transaction]──> Process Transaction
    |                              |              |    |    |
    |                    [No Data]──> End Process  |    |    |
    |                                              |    |    |
    +────────[System Exception]────────────────────+    |    |
             [Business Exception]───────────────────────+    |
             [Success]───────────────────────────────────────+
                              (both go back to Get Transaction Data)

Argument default values on root Activity: REFramework Main.xaml sets argument defaults using the this: namespace prefix (e.g., this:Main.in_boolAttendedRun="True" on the <Activity> element). The this: prefix references the workflow's own class namespace. Scaffold handles this.

Data Manipulation Activities

Publish your skill

Copy this prompt into Claude Code, Codex or any agent. It walks you through your first skill in about 20 minutes, with you as the author.

Click to copy.