# Variables

Any task can use predefined variables. These variables are created through Developer Console and defined as JSON object. This JSON object is next transformed to input fields and available on User Dashboard in user friendly way.

This is how different parameters of task can be configured.

Example JSON variables definition might look like this:

```
{
  "checkbox#ENABLED": true,
  "short_text#ORDER_EXPORT_PATH": "/new_path/",
  "short_text#USER": "user@ftp.com",
  "short_text#HOST": "ftp.com"
}
```

JSON property name consists of variable type and variable name and is separated with `#`. JSON property value is just our variable value.

In your code you would referance variable by its name. To output second variable you would type: `{{ ORDER_EXPORT_TYPE | log }}`

Above snippet would look like this on User Dashboard:

<figure><img src="/files/lzibyrHkobE3YFOQLRsI" alt=""><figcaption></figcaption></figure>

Variable type might be one of the following:

```javascript
short_text
short_texts
long_text
collection
collections
customer
customers
date_time
json
location
locations
metaobject
metaobjects
product
products
product_variant
product_variants
order
orders
checkbox
script
scripts
select
section
```

#### section (repeatable group)

A `section` is a repeatable group of inner scalar fields. Use it for "list of structured rows" configurations such as loyalty tiers, shipping bands, or commission slabs. Merchants get a dashboard editor with **Add** and **Remove** buttons for each row, and Liquid can iterate the value natively — no `| parse_json` filter is needed.

Prefer `section` over `json` for any repeating-row configuration.

The value is an array of plain objects whose keys match the inner-field schema:

```
{
  "section#TIERS": [
    { "name": "Silver", "threshold": "100" },
    { "name": "Gold",   "threshold": "500" },
    { "name": "Platinum", "threshold": "1000" }
  ],
  "metadata": {
    "TIERS": {
      "helpText": "Define tier thresholds — order from lowest to highest",
      "maxArrayLength": 10,
      "fields": [
        { "name": "name",      "type": "short_text", "label": "Tier name", "required": true },
        { "name": "threshold", "type": "short_text", "label": "Min spend", "subtype": "number", "required": true }
      ]
    }
  }
}
```

`metadata.<NAME>.fields` is required and must be a non-empty array. Each field needs a `name`, a `type`, and an optional `label`. Allowed inner `type` values are: `short_text`, `long_text`, `checkbox`, `date_time`, `select`. Sections cannot be nested.

Numeric values are stored as strings (same convention as `short_text` with `subtype: "number"`); use `| times: 1` in Liquid for numeric comparisons.

Iterate in Liquid:

```
{% for tier in TIERS %}
  {% log tier.name %}
  {% if customer_total | times: 1 >= tier.threshold | times: 1 %}
    {% assign reached_tier = tier.name %}
  {% endif %}
{% endfor %}
```

### Metadata

For all variable you can define metadata where you would specify additional variable context. To the variables JSON definition add new special property called `metadata` where you can define additional input field configuration.`helpText` or `options` (only for `select` field).

Available metadata properties are:\
\- `subtype` - applicable to short\_text field only. Might be one of the following: `password`, `email`, `number`, or `integer`\
\- `min` - min value of `short_text` with number subtype\
\- `max` - max value of `short_text` with number subtype\
\- `minLength` - min number of characters in `short_text`\
\- `maxLength` - max number of characters in `short_text`\
\- `maxArraySize` - applicable only to array variables, specifies max number of elements in an array\
\- `helpText` - help text displayed below input field\
\- `step` - step of `number` subtype\
\- `pattern` - regex pattern for input field\
\- `showCharacterCount` - shows current number of characters in input field\
\- `options` - applicable only to `select` field. Contains list of available options for select field.\
\- `visibleIf` - only shows the field if field reference as value evaluates to true\
\- `metaobjectType` - used only for metaobject or metaobjets variable. It is required to allow metaobjects search

```
{
  "select#VARIABLE_WITH_OPTIONS": "",
  "short_text#EXAMPLE_VARIABLE_WITH_STEP": "6",
  "metadata": {
    "VARIABLE_WITH_OPTIONS": {
      "options": [
        {
          "label": "A",
          "value": "a"
        },
        {
          "label": "B",
          "value": "b"
        },
        {
          "label": "C",
          "value": "c"
        }
      ],
      "helpText": "This is a select input field"
    },
    "EXAMPLE_VARIABLE_WITH_STEP": {
      "subtype": "number",
      "step": "0.5",
      "min": "3",
      "max": "10"
    }
  }
}
```

metadata property is not considered as variable therefore can't be access from script logic


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.datajet-app.com/misc/variables.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
