# Workflow Data

> How to point a step at a value an earlier step produced, and how to see what a step actually produced.

Every step in a workflow takes in data, does something with it, and produces data of its own that any later step can use. This page covers how to reference an earlier step's value, and how to see what a step actually produced when the answer surprises you.

## How data flows

When a workflow runs, data travels step by step along the links you drew on the canvas.

The trigger captures whatever started the run and passes it to the first step. That might be data a webhook received or a person clicking Run. A schedule trigger carries no data of its own: a later step that needs the time uses `{{ $now }}`. The first step produces its own output, which passes to the next, and so on.

Each step's output is preserved for the duration of the run. This means a step near the end of the workflow can reference data from any earlier step, not just the one immediately before it.

```mermaid
flowchart LR
    A[Trigger Payload] --> B(Step 1 Output)
    B --> C(Step 2 Output)
    C --> D(Step 3 Output)
    B -.->|Reference upstream data| D
```

## Referencing Data (The Workflow Data Panel)

To use data from an earlier step, point at it with the **Workflow data** panel.

Click the data icon at the right of any field in a step's setup and the panel opens with three tabs:

| Tab                     | What it does                                                                                          |
| ----------------------- | ----------------------------------------------------------------------------------------------------- |
| **Data select**         | Every earlier step and what it produced, as a tree you expand. This is where you pick a value.        |
| **Data flow**           | How data moves between steps, and when each connection last carried anything.                         |
| **Data transformation** | Tidy a value before this step uses it: see [Tidying a value](#tidying-a-value-before-a-step-uses-it). |

Data select also holds **System Variables** (`$now`, `$today`, the workflow creator's email) and **Team Variables and Secrets**.

### Open the panel

Click the data icon at the right of the field you are filling in. The panel opens on **Data select**.

### Pick the value

Expand the tree and click the value you want, for example `Step 1 (Webhook) > email`.

### Check the badge

The value appears in the field as a coloured badge. That badge is the sign it is mapped to live data rather than typed as text.

### Writing a reference by hand

**Steps are referenced by their number**, the one shown beside them on the canvas. A reference is that number, then the path into what the step produced, wrapped in double braces: `{{ 1.email }}`.

There is no name-based form. `{{ trigger.email }}` and `{{ webhook.email }}` do not work.

To reference everything a step produced rather than one field, use just the number, `{{ 1 }}`, or `{{ 1.$full_result }}`.

The path after the number depends on the step. Pick from the data selector rather than typing from memory: a reference that finds nothing fails the step rather than sending an empty value onward.

You can mix plain text with references. In an email subject field, for example:
`New lead received from: {{ 1.name }}`

Alongside step numbers, a few built-in references are always available:

| Reference                                        | Meaning                                      |
| :----------------------------------------------- | :------------------------------------------- |
| `{{ item }}` / `{{ item.field }}`                | The current item in "Run for each item" mode |
| `{{ item.$index }}` / `{{ item.$total }}`        | Position in, and size of, the current batch  |
| `{{ $now }}` / `{{ $today }}`                    | Current UTC datetime / date                  |
| `{{ $var.KEY }}` / `{{ $secret.KEY }}`           | Team variable / team secret                  |
| `{{ $file. }}`                               | Team file                                    |
| `{{ $webhook.1.url }}`                           | Deployed URL of the webhook at step 1        |
| `{{ $workflow_url }}` / `{{ $workflow_footer }}` | Workflow canvas URL / markdown backlink      |

> If you are not sure what a step produces, run the workflow once before mapping
> anything downstream. Data select then shows the values from that run instead
> of a list of field names: an actual email subject, an actual row.

## Tidying a value before a step uses it

The **Data transformation** tab lists every value the step reads from earlier steps, and lets you clean each one up on the way in: trim stray spaces, change capitalisation, format a number for reading, pull the domain out of an email address, reformat a date, or fall back on something else when a field arrives empty.

A value that arrives as a list has its own operations: take the first or last item, count the items, or join them into one piece of text. Take one item and the ordinary operations open up on it. The menu offers only the operations that fit the value it sees, so a number is offered rounding and a date is offered date arithmetic.

**Format for reading** adds thousands separators and fixes the decimal places. Its settings are **Decimal places** (2 by default) and a **Style** with three punctuation choices: `1,234.56`, `1 234,56` and `1.234,56`.

It happens where the value is used. Nothing is added to the canvas, and the step before it is unchanged, so tidying a value for one step does not affect any other step reading the same field.

**It only lists values from earlier steps.** A system variable such as `{{ $now }}` is generated fresh on every run, so there is nothing to tidy and it does not appear here.

**If a value shows as empty**, the step it comes from has usually not run yet. Run that step once and its data is available to transform.

> For the complete catalog of all math calculations, date snapping, timezone
> conversions, list operations, and text security tools available inside fields,
> see the full [Data Transformation](/build/core-concepts/data-transformation)
> guide.

## Variables

Variables let you store and reshape data inside a workflow. Use them to hold an in-between value, do a calculation, or assemble a piece of text before the next step needs it.

A variable lasts for one run and no longer. The next run starts without it.

## Inspecting data

Glow provides several ways to inspect data as it moves through a workflow:

  - [Executions Tab](/build/core-concepts/executions): Select any step on the canvas, open the app drawer, and switch to the **Executions** tab to see input and output data.
  - [Data Preview](#referencing-data-the-workflow-data-panel): Data select shows the value each field currently holds, so you can confirm you are referencing the right one before you pick it.
  - [Code editor & HTTP Request](/build/action-steps/code-execution): Add a code or logging step mid-workflow to print intermediate data to the execution log for deeper inspection.

### Debugging with Executions

When debugging a failing workflow, the best approach is to work backwards.

### Start at the failure

Identify the step that failed or produced the wrong result.

### Inspect the input

Open the step above it and run it in **Test & Debug**: its output is what the failing step received.

### Trace upstream

If the input is wrong, move to the previous step and inspect its output. Keep going upstream until you find the step producing the unexpected value.

## What's Next?

- 👉 **[Mapping or Transforming Data →](/build/core-concepts/mapping-or-transforming)**: choose between direct mapping, an in-field transformation, a list Step, AI and code.
- **[Data Transformation](/build/core-concepts/data-transformation)**: tidy text, calculate numbers and format dates without extra Steps.
- **[Kinds of Data](/build/core-concepts/data-types)**: learn how records, arrays and file objects travel across the canvas.
