Data Transformation

Purpose

Data Transformation is the core logic layer in the Rules system.
It is used to process and react to the data that is passed into a Smartform when it is created.

Using Data Transformation, you can take incoming DataTable values, evaluate them, and convert them into values that control how the Smartform behaves.

Typical uses include:

  • Reacting to incoming data (for example age, role, or status)
  • Updating or creating new variables based on conditions
  • Applying IF / ELSE logic
  • Categorizing or splitting data
  • Preparing values that are later used by Show/Hide rules or dynamic text

How Data Transformation Works

Data Transformation rules operate on Variables.

These variables are populated when the Smartform is created:

  • Via API
  • Via Workflow
  • Or via a Dataset for testing

Each rule evaluates variable values and can update existing variables or set new ones.

A single Data Transformation rule consists of:

  1. Rule Name
  2. Execution Mode (Always Run or Conditional)
  3. Conditions (IF) – optional
  4. Actions (THEN)
  5. Actions (ELSE) – optional

Rule Execution Order

  • Rules are executed sequentially
  • The result of one rule is available to the next rule
  • Earlier rules should prepare or normalize data
  • Later rules should apply business logic

Rule order directly affects the final result.


Creating a Data Transformation Rule

Step-by-step

  1. Open the Smartform in Studio
  2. Go to Rules
  3. Select Data Transformation
  4. Click Add Rule
  5. Enter a descriptive Rule Name
  6. Choose execution mode and configure logic
  7. Click Add Rule to save

Always Run

When Always Run is enabled, the rule executes every time the Smartform is created.

Behavior

  • No conditions are required
  • The Conditions section is hidden or simplified
  • Only THEN actions are available
  • ELSE actions are not applicable

Typical Use Cases

Use Always Run for rules that should always apply, such as:

  • Formatting text values
  • Initializing variables
  • Copying values from one variable to another
  • Normalizing incoming data
  • Calculating derived values

Conditional Rules (Always Run Disabled)

When Always Run is disabled, the rule only runs when conditions are met.

Conditions (IF)

Conditions determine whether the rule should execute.

  • Conditions are organized into Condition Groups
  • Conditions within a group can use AND / OR
  • Multiple condition groups are combined using AND
  • All condition groups must evaluate to true

Example logic:

  • (age < 18) AND (country = "NO")

Actions (THEN)

Actions define what happens when the rule runs.

Set Value

  • Assigns a value to a variable
  • The value can be:
    • A static value
    • Another variable
    • A formula

Example:

  • If age < 18, set variable under18 to true

Case / Switch

  • Assigns values based on multiple cases
  • Useful for:
    • Mapping input values
    • Categorizing data
    • Replacing complex IF / ELSE chains

ELSE Actions (Optional)

ELSE actions run when IF conditions are not met.

Common uses:

  • Setting default values
  • Clearing variables
  • Assigning alternative outcomes

ELSE actions use the same action types as THEN actions.


Using the Formula Editor

When setting a value, you can open the Formula Editor.

The Formula Editor allows you to:

  • Reference variables using {{variableName}}
  • Use built-in functions
  • Combine variables, functions, and static values

Function Categories

  • Text – formatting, trimming, joining, substring
  • Number – formatting and calculations
  • Date – formatting, offsets, comparisons
  • Table – filtering, mapping, merging, counting

The syntax preview helps verify the formula before applying it.


Practical Example

Incoming data:

  • age = 17

Rule logic:

  • IF age < 18
    • Set variable isMinor = true
  • ELSE
    • Set variable isMinor = false

Result:

  • The Smartform can display different text or sections based on isMinor
  • For example:
    • Show a message like “You cannot sign without a parent or guardian”
    • Adjust instructions or requirements dynamically

Dependencies

  • Variables must exist before they can be used or updated
  • Variable names must match incoming DataTable keys
  • Table variables require consistent structure
  • Data Transformation runs before Show/Hide rules

Best Practices

  • Use clear and descriptive rule names
  • Keep each rule focused on a single purpose
  • Place Always Run rules early
  • Use conditional rules for business logic
  • Prefer Case / Switch for complex mappings
  • Verify logic using the Test Runner

Data Transformation is the foundation of dynamic Smartforms.
It enables Smartforms to adapt their content, logic, and behavior based on incoming data.