> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mercora.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Use values from earlier steps

> Fill a step's fields with values from the trigger, from an earlier step, or typed in, and ask an AI step to hand a value back by name.

Most fields in a step take a value: the reference to look up, the record to update, the value an If checks, the words of a note. You fill them by picking a value by name. Each picked value shows as a chip that says where it comes from:

* **from the document · Invoice number**: a field of the document that started the run.
* **from the request · Contract number**: a field another system sent.
* **from step 1 · Its id**: what step 1 found.
* **from step 1 · Matches contract**: a value you asked AI step 1 to hand back.
* **USD**: a value you typed.

When the run reaches that step, each chip is replaced by its value.

## Where values come from

A step can use values from the trigger and from any step above it, never from a step below.

| Where it comes from | Values you can pick |
| - | - |
| The trigger: a document | Under **From the document**: **The document**, **Its trade**, and every field extracted from the chosen document types, such as **Invoice number**, **Due date** or **Contract number** |
| The trigger: another system's call | Under **From the request**: the fields you listed under **Fields it sends** |
| The trigger: an email, Teams post or WhatsApp message | Under **From the message**: **The message**, **Who sent it**, **The sender as a member**, **Where it arrived**, **The subject** (email), **When it arrived**, **Its files** |
| A **Work something out** step | Any value you name. See [Ask an AI step for a value](#ask-an-ai-step-for-a-value) |
| A **Find a record** step | **Its id**, **Reference**, **Its trade**, **Counterparty**, **Quantity**, **Price**, **Currency**, **Amount** |
| A **Find contacts** step | **Their email addresses**, **Their names**, **Counterparties**, **How many** |
| An **Update a record** step | **Its id** |
| A **Make a confirmation** step | **The confirmation**, **Its file name** |
| An app action | The values the action returns, listed by name |
| An **Ask someone to approve** step | **What was approved** |
| An **Ask someone a question** step | **The answer** |
| A **Wait for** step that waits for a document | **The document**, **Its type** |
| A **Wait for** step that waits for a callback | Any value you name, as the call sends it |

In the list, an earlier step's values sit under **From step** *N* and the step's sentence, such as **From step 2 · Alex Morgan approves what step 1 drafted**. A Mercora or app step is headed by its action's name, such as **From step 1 · Find a record**. An AI step, and a **Wait for** step that waits for a callback, have no list: type a name to ask them for a value.

A schedule or **Only when someone runs it** hands the steps no values. **If**, **Tell someone**, **Report a finding** and **Stop here** hand nothing on.

## Pick a value

1. Open the step and click the value box. An empty one reads **Pick a value**.
2. The list shows each source as a heading, the trigger first, then each earlier step, with its values under it. Scroll, or type to search.
3. Click a value. The box now shows it as a chip.

![The value list open on an If step, with the headings From the request and From step 1 · Find a record](https://mintcdn.com/placeholder-f4ffdeec/s6Fb5kGGc4sLUuXY/images/workflows/automations/value-picker.png?fit=max\&auto=format\&n=s6Fb5kGGc4sLUuXY\&q=85\&s=b6848ae21652f62dbf937aac746ec6ba)

Step 2 can pick from the request's fields and from what step 1 found.

To change a value, click its chip and pick another. In text (a finding or a note), click a chip and pick **Remove this value** to take it out.

## Ask an AI step for a value

An AI step has no fixed list of values: it works out whatever its brief asks. So a later step names the value it needs, and the AI step hands it back.

**1. Open the later step's value box**

In the step that needs the value, click **Pick a value**. Here, an If in step 2 that should check whether the invoice matches its contract.

**2. Type a name for the value**

Type what the value is, such as `Matches contract`. Two choices appear: **Use "Matches contract" as a typed value**, and **Ask step 1 for "matches contract"** (one line for each AI step above).

![The value list with Use "Matches contract" as a typed value and Ask step 1 for "matches contract"](https://mintcdn.com/placeholder-f4ffdeec/s6Fb5kGGc4sLUuXY/images/workflows/automations/value-picker-ask.png?fit=max\&auto=format\&n=s6Fb5kGGc4sLUuXY\&q=85\&s=885dc6b3cf2b4d151eec7f9a0dc39f70)

Type a name, then click Ask step 1 for "matches contract".

**3. Click Ask step 1**

The box now reads **from step 1 · Matches contract**. Finish the rule: here, the test **is no**.

![An If step: from step 1 · Matches contract is no](https://mintcdn.com/placeholder-f4ffdeec/s6Fb5kGGc4sLUuXY/images/workflows/automations/step-if.png?fit=max\&auto=format\&n=s6Fb5kGGc4sLUuXY\&q=85\&s=24da01a8736b107daf2c947ce927de26)

The If checks the value step 1 hands back.

**4. Say how to work it out in the brief**

Open step 1 and make sure its brief explains the value, such as "Say whether price, quantity and currency all match the contract."

**What happens in a run.** Step 1 is told to hand back every value that later steps ask of it, by name. Each value's kind comes from how it's used:

| Where the value is used | Step 1 hands back |
| - | - |
| **is yes** or **is no** in an If | Yes or no |
| **is more than** or **is less than** in an If | A number |
| **Until a date from an earlier step** in a Wait for | A date |
| **On the trade** in a Wait for | A trade |
| A field of a Mercora or app step | What that field takes |
| Anywhere else (text, **is**, **contains**) | Text |

If step 1 can't work the values out, the step fails and names the values later steps need, such as "Step 1 finished without the values step 2 needs: matches\_contract". It never invents one. Then the step's [failure plan](https://docs.mercora.io/workflows/automation-steps.md#if-a-step-fails) applies. If step 1 ends with nothing to report, it hands back nothing and the run carries on, so later steps find each value empty (see [When a value is missing](#when-a-value-is-missing)).

To use the same value in another step, ask for it again with the same name. In the [due date example](https://docs.mercora.io/workflows/automation-examples.md#fix-an-invoices-due-date-from-its-contract), steps 2 and 3 both ask step 1 for "due date", and step 1 hands it back once.

A name becomes lower\_snake\_case: `Broker name` is asked for as `broker_name` and shows as **Broker name**. Use a name that says what the value is, since step 1 reads it.

## Type a value

Click the value box, type the value, and click **Use "…" as a typed value**. A plain number, such as `1200` or `3.5`, is kept as a number; anything else is text. Use it for a fixed value, such as `USD` in a rule "from step 1 · Currency **is** USD".

A typed value can't stand where Mercora needs a real record, such as the trade a **Wait for** step watches: pick that from the trigger or an earlier step.

## Write text with values

A **Report a finding** text and a **Tell someone** note mix your words with values:

1. Type the first words in the box.
2. Click **+ value** and pick a value. It goes in after your words, and a new box opens after it.
3. Type the next words in the new box. Repeat for each value.

![A Tell someone note with text and the value from step 2 · The answer](https://mintcdn.com/placeholder-f4ffdeec/s6Fb5kGGc4sLUuXY/images/workflows/automations/value-answer.png?fit=max\&auto=format\&n=s6Fb5kGGc4sLUuXY\&q=85\&s=4cdd55b0f8313e62fbdebf7d90916eea)

The note ends with the answer to the question in step 2.

In the run, each value is written into the text, such as "Credit note account: 4010 Sales returns". The step's sentence in the list shows each value by its name ("Tell Alex Morgan: Credit note account: the answer").

## When a value is missing

A value that isn't there is never guessed. It counts as empty:

* In an If, only **is empty** holds for it; every other test fails. Check with **is not empty** before a step that needs the value.
* A Mercora or app step that needs it fails and names the input with no value, such as "Step 2 has no value for number."
* In text, it adds nothing.

## Fix a value whose step is gone

A value's source can go: the step it came from was deleted, or moved below the step that uses it. In a step's fields, the first value of an If rule, and a finding or note, its chip then turns red. In the second value of an If rule, a **Wait for** date or trade, and the fields of **Update a record**, its chip reads "from a deleted step" instead. Either way, click the chip and pick another value. **Save** won't save the automation until every value can be found, and says which step to fix.

## Next steps

* [Examples](https://docs.mercora.io/workflows/automation-examples.md): four automations that pass values from step to step.
* [Steps](https://docs.mercora.io/workflows/automation-steps.md): the fields of each step.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.