Set Default Value

Overview

Set Default Value assigns a value to a variable only when that variable does not already exist or is empty in the flow dictionary. Unlike Change Data, which always overwrites the existing value, Set Default Value preserves any value that is already present. This makes it useful for setting fallback values and initializing optional parameters.

Note: The variable names, values, criteria, and configuration used in this example are for demonstration purposes only.

Configuration

Required Fields

FieldDescriptionExample
ValuesOne or more key-value pairs to set (at least one required)Variable: userRole, Default: guest

Each value pair consists of:

Sub-fieldDescriptionExample
Variable NameName of variable to create (without brackets)apiTimeout, retryCount
Default ValueValue to assign if variable doesn't exist or is empty30, guest 
=({{baseValue}} * 2)

Exit Points

ExitWhenFlow Direction
PassAlways (all default values processed)✓ Variables created where needed, skipped where already exist

How It Works

When executed, Set Default:

  1. Processes each variable pair - Iterates through all configured variables
  2. Checks if variable exists - Looks for variable in flow dictionary
  3. Checks if value is empty - Tests if existing value is empty string (after trim)
  4. Assigns default conditionally - Only sets value if variable missing or empty
  5. Preserves existing values - Skips assignment if variable exists with non-empty value

Key Difference from Change Data: Set Default only assigns when variable is missing or empty; Change Data always overwrites.

Common Use Cases

1. API Timeout Default

  • Variable: apiTimeout
  • Default Value: 30
  • Result: If apiTimeout doesn't exist → created with value 30; If already 60 → stays 60

2. User Role Default

  • Variable: userRole
  • Default Value: guest
  • Result: If userRole missing or empty → becomes "guest"; If already "admin" → stays "admin"

3. Multiple Defaults

  • Variable 1: retryCount = 3
  • Variable 2: maxRetries = 5
  • Variable 3: delayMs = 1000
  • Result: Initialize several optional parameters at once

4. Optional Webhook Fields

  • Variable: notificationEmail
  • Default Value: [email protected]
  • Result: Provide fallback email if webhook doesn't include one

5. Formula-Based Defaults

  • Variable: discountAmount
  • Default Value: =({{price}} * 0.1)
  • Result: Calculate default 10% discount if not specified

Key Behaviors

FeatureBehavior
Conditional AssignmentOnly sets value if variable missing or empty
Empty String HandlingEmpty strings (after trim) treated as "not existing"
Formula Support✓ Default values starting with = are evaluated as formulas
Variable References✓ Can reference other variables: {{defaultConfig}}
Multiple VariablesCan set any number of defaults in single stage
Always SucceedsNo Error exit; always routes to Pass

Best Practices

  • ✓ Use for optional API parameters or webhook fields
  • ✓ Initialize variables that may not be present from earlier stages
  • ✓ Place early in flow to ensure variables exist before use
  • ✓ Use meaningful defaults that make sense for your use case
  • ✓ Document why each default value was chosen
  • ✓ Combine multiple related defaults in single stage
  • ✓ Use formulas for calculated defaults: =({{baseValue}} * 2)

Common Mistakes

MistakeSymptomFix
Expecting to overwrite existing valuesExisting values not changedUse Change Data instead to always overwrite; Set Default preserves existing
Empty strings not replacedEmpty values remain emptySet Default DOES replace empty strings; verify configuration
Using with curly braces in variable nameVariable not created correctlyEnter plain name: "apiTimeout" not "{{apiTimeout}}"
Formula not evaluatingLiteral formula text storedEnsure formula starts with = sign: ={{value}}
Assuming values are requiredConfusion about stage purposeSet Default is for optional fields; use validation for required fields

Troubleshooting

IssueExit/ResultCommon CauseFix
Default not appliedPassVariable already exists with non-empty valueThis is expected behavior; use Change Data to overwrite
Empty value not replacedPassValue has whitespace (not truly empty)Set Default trims before checking; verify actual value
Variable not createdPassVariable name field empty or invalidEnsure variable name is provided and valid
Formula produces wrong resultPassReferenced variables don't exist or formula incorrectVerify all referenced variables exist before Set Default stage

Edge Cases

  • Variable exists with non-empty value: Default not applied; existing value preserved
  • Variable exists with empty value: Default IS applied; empty replaced with default
  • Variable doesn't exist: Default applied; variable created
  • Formula evaluation errors: Handled at variable resolution level
  • Multiple variables with same name: Last one wins (not recommended)

Related Stages

  • Change Data: Always overwrites values (vs conditional assignment)
  • Look Up Value: Use after Set Default to map default values
  • Route Flow: Check if variables were set or used defaults