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

# Set global variable

> Sets a variable in the global scope.

export const FormField = ({property, label, required = false, diType, uiPatterns, children}) => {
  const patterns = Array.isArray(uiPatterns) ? uiPatterns : uiPatterns ? [uiPatterns] : [];
  return <div style={{
    margin: '1.5rem 0'
  }}>
      <div style={{
    display: 'flex',
    alignItems: 'baseline',
    flexWrap: 'wrap',
    gap: '0.5rem',
    marginBottom: '0.25rem'
  }}>
        <strong>{label}</strong>
        <span style={{
    fontSize: '0.7rem',
    fontWeight: 600,
    textTransform: 'uppercase',
    letterSpacing: '0.04em',
    color: required ? '#6241f5' : '#6b7280'
  }}>
          {required ? 'Required' : 'Optional'}
        </span>
      </div>

      <div>{children}</div>

      {diType || patterns.length > 0 ? <p style={{
    fontSize: '0.85rem',
    color: '#6b7280',
    marginBottom: 0
  }}>
          {diType ? <>
              See the <a href={`/references/${diType}`}>{diType}</a> reference.{' '}
            </> : null}
          {patterns.length > 0 ? <>
              Accepts a <a href={`/documentation/placeholders-and-patterns/patterns#${patterns[0]}`}>pattern</a>.
            </> : null}
        </p> : null}
    </div>;
};

Sets a variable in the global scope. Use this to remember a value once and reuse it anywhere later in the same run, even across different steps. You give the variable a name and a value (which can pull in data from the item currently being processed), and from then on you can drop that value into any field with the placeholder `@{globals.<name>}`. It is handy for things like a default shipping country, a batch reference, or a timestamp that several later steps all need to share.

This step does not change the item itself; it only stores the value behind the scenes for the rest of the run to use.

This documentation describes: [Schema](/schemas/transformer/global-variable-setter)

## Fields

<FormField property="key" label="Key" required uiPatterns="path">
  The name you give the variable. You read the value back later with the placeholder `@{globals.<key>}`, so a key of `default_country` becomes `@{globals.default_country}`. Pick a short, descriptive name.
</FormField>

<FormField property="value" label="Value" required>
  The value to store under that name. You can type a fixed value or use a placeholder such as `&{order.customer.country}` to capture data from the item currently being processed. The placeholder is filled in at the moment this step runs, and the result is what gets saved. See [Placeholders](/references/placeholders) for the full syntax.
</FormField>

## Sample data

This example stores the item's country as a global variable named `default_country`, then a later step reads it back with `@{globals.default_country}` and writes it to `shipping_country`. The stored value is kept behind the scenes, so the visible change shows up only once a later step uses it.

| Field | Value                       |
| ----- | --------------------------- |
| Key   | `default_country`           |
| Value | `&{order.customer.country}` |

Input:

```json theme={null}
{
    "order": {
        "customer": {
            "country": "NL"
        }
    }
}
```

Output:

```json theme={null}
{
    "order": {
        "customer": {
            "country": "NL"
        }
    },
    "shipping_country": "NL"
}
```

```json Configuration theme={null}
{
  "prototype": "global-variable-setter",
  "parameters": {
    "key": "default_country",
    "value": "&{order.customer.country}"
  }
}
```
