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#PASSWORD": "password",
  "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:

Variable type might be one of the following:

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

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.

{
  "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

Last updated