Altoura Training
Copy link
Creator

Set Variable

Set or update a variable's value during training execution

Overview

The Set Variable action allows you to modify or update existing writable variables throughout your training. Variables store data that persists across states and transitions, enabling you to track learner progress, record choices, and implement conditional logic.

When to Use

  • Track scores or counts: increment a score each time a learner completes a task
  • Record learner choices: store which option the learner selected
  • Set flags: mark milestones (e.g., isComplete = true, hasAttempted = false)
  • Compute derived values: calculate new values based on existing variables using expressions
  • Enable conditional logic: set variables that transitions or branching logic can check

Parameters

ParameterTypeRequiredDescription
VariableselectionYesSelect an existing writable variable. Create it in the Variables pane first; an unknown name does not create one.
Variable pathstringNoA valid supported path within the selected variable, when assigning a nested value.
Set Value / Set ExpressionmodeYesChoose a typed literal value or an AXL expression. The result must match the target type.

Data Types

Variables can store:

  • string: "text", "completed", "user input"
  • number: 10, 3.14, -5
  • boolean: true, false
  • array: lists of values

Internal and read-only variables cannot be assignment targets. Set Value uses the target type, including a Boolean selector and JSON input for Arrays. Enter expressions directly in Set Expression, without {{...}}.

Expression Examples

Use AXL expressions to compute or reference values dynamically:

score + 10              → adds 10 to the current score
attempts - 1            → subtracts 1 from attempts
"completed"             → literal string
true                    → literal boolean
score >= 80 ? "pass" : "fail"  → conditional: if score ≥ 80, set to "pass", else "fail"
learnerName + " passed" → concatenate strings
attempts <= 3           → boolean expression (true/false)

Practical Example

Scenario: A training module where learners attempt a repair task. Track every attempt, including the successful one, and set a completion flag when they succeed. Award 100 points for success within three attempts, or 50 points for success on a later attempt.

First create Number variables attempts and finalScore, and Boolean isComplete in the Variables pane. New Number variables start at 0, and a new Boolean starts at false. Keep the attempt count across retries.

Count each attempt when it starts

In the Repair Task step's On Entry actions, add Set Variable:

  • Variable: attempts
  • Set Expression: attempts + 1

Entering this step starts a new attempt. The first entry changes attempts from 0 to 1; each retry increases it once more.

Return to the repair step for a retry

On failure, transition to an Attempt Failed step. Set its retry transition's target to Repair Task so the next attempt runs the same On Entry increment. Do not increment or reset attempts in Attempt Failed.

Record completion and calculate the score

On success, transition to Repair Successful. In that step's On Entry actions, add two Set Variable actions:

  • Variable: isComplete
  • Set Value: true

And:

  • Variable: finalScore
  • Set Expression: attempts <= 3 ? 100 : 50

The successful attempt has already been counted. Success on attempt 1 or 3 awards 100 points; success on attempt 4 awards 50 points.

Use the recorded values later

Later, use the attempts or isComplete variables in a transition condition to branch to different states (e.g., show a "Congratulations" screen only if isComplete == true).

Was this page helpful?
© 2026 Altoura
Enter a page title, topic, or keyword.