Data Pills & Input Modes
Reference outputs from earlier steps with data pills, and switch fields between Text and Formula input modes.
A property field can hold a constant, a reference to the output of the trigger or an earlier step (a data pill), or a computed value (a formula). This page describes data pills and the two input modes of every field: Text and Formula.
Data Pills
A data pill is a reference to data produced earlier in the workflow: the trigger payload or the output of a step that runs before the current step. ByteChef resolves the pill to its value at run time.
A pill is stored as a ${...} reference, for example:
${mathHelper_1}- the whole output of the step namedmathHelper_1.${trigger_1.body.email}- a nested field inside an earlier step's output.
The name in the reference is the node name, not the component name. Action nodes
are named after their component (mathHelper_1, slack_1); the trigger node is
always named trigger_1 whichever component provides it, so a webhook trigger's
body is ${trigger_1.body...}.
The editor inserts this syntax for you and renders it as a colored pill. The ${...} form is what
the workflow JSON stores.
Example: a webhook payload as data pills
Suppose a webhook trigger receives this request:
curl -X POST "<webhook URL>" \
-H "Content-Type: application/json" \
-d '{
"firstName": "Ada",
"email": "ada@example.com",
"order-id": "A-1001",
"items": [
{"sku": "KB-01", "quantity": 2},
{"sku": "MS-07", "quantity": 1}
]
}'The trigger output has method, headers, parameters (the query parameters) and body. The
fields of the JSON body are pills under body:
| Data pill | Resolves to |
|---|---|
${trigger_1.body.firstName} | Ada |
${trigger_1.body['order-id']} | A-1001 |
${produceReport.outputFiles['report.csv']} | The report.csv entry of a map keyed by file path |
${trigger_1.body.items} | The whole items list |
${trigger_1.body.items[0].sku} | KB-01 |
A key that contains characters other than letters, digits and _, or starts with a digit, such as order-id,
report.csv or charts/summary.txt, is written in bracket notation. The editor does this for you when you insert the
pill. A bracketed key cannot contain a ', a \, a {, a } or a line break.
When you insert a field from inside a list, the pill points to the first item, [0]. Click the
index on the pill to pick another item. To process every item, use a
Loop or a
projection instead.
In the workflow JSON, the pills are stored inside the step's parameters:
{
"name": "slack_1",
"type": "slack/v1/sendChannelMessage",
"parameters": {
"channel": "C01234567",
"text": "New order ${trigger_1.body['order-id']} from ${trigger_1.body.firstName} (${trigger_1.body.email})"
}
}Use the Data Pill Panel
- Click into a property field. The Data Pill Panel opens on the left, listing the trigger and every component that runs before the current one. This works for every kind of field: text, numbers, true/false, dates and dropdowns.
- Expand a component to see the fields available in its output.
- Click a field to insert it as a pill. In a text field the pill goes in at the cursor; in any other field it replaces the value. You can also drag a pill from the panel onto a field.
You can also type $ in the field to open an inline data-pill picker without using the panel.
Only steps that run before the current component appear in the Data Pill Panel. A component can never reference the output of a step that runs after it.
Make sure the output schema is available
Data pills are built from each step's output schema. If a component has not been tested and has no predefined schema, its fields do not appear as pills. Open the component's Output tab and use one of:
- Test Action - runs the action and reads the real output structure.
- Upload Sample Output Data - provide your own representative output.
- Reset - show the structure with placeholder sample values.
See Output on the Workflows page.
Input Modes
Every property field has two modes, shown as switches next to its label. Text is the default and covers constants and data pills; Formula computes the value with an expression.
Text mode
In Text mode you type a constant, insert data pills, or both. What a field accepts depends on its type:
- Text fields mix typed text and any number of data pills, e.g.
Hello ${trigger_1.body.firstName}, your order shipped. - Numbers, true/false and dates hold either a constant in the regular input or exactly one
data pill. Click a pill in the panel (or type
$in an empty field) to replace the constant with a pill; delete the pill to get the regular input back. - Dropdowns, dates, arrays and objects have an extra Text switch. Turn it on to replace the selected option, the date or the items with a data pill, for example a list produced by an earlier step. Turn it off to get the regular control back. A dropdown of text values also accepts typed text around its pills.
- Code fields that accept expressions have the Text and Formula switches too. Turn Text on to use a data pill as the code, for example code produced by an earlier step. Turn Formula on to build the code with an expression. With both off, the field opens the regular code editor.
Turning the Text switch on for an array or object that already has items asks before it replaces them, because the data pill becomes the whole value and the items are removed.
Formula mode
When a field needs a computed value, such as joining strings, formatting a date or doing
arithmetic, turn on its Formula switch, or type = in an empty field. The field gets a violet
frame to show it holds a formula.
You type the expression without the leading =; ByteChef stores it with one, which is the form
the examples on this page use. Typing 1 + and then clicking the Number pill of var_1 saves
=1 + ${var_1.Number}.
In formula mode you can:
- Reference data pills inside the expression, e.g.
=concat(${trigger_1.body.firstName}, ' ', ${trigger_1.body.lastName}). - Call built-in functions. As you type a function name, an autocomplete list and a signature tooltip appear to guide you.
Formula editor
A long formula is hard to read in a one-line field. In formula mode, click the expand button before the Formula switch to open the formula in a larger editor that opens over the field. The editor works like the field: it has the same autocomplete, it takes data pills when you click them in the Data Pill Panel, and it saves as you type. Close it with its X button, Esc, or a click outside the editor.
On a text area or rich text field, the same expand button opens the full-size side panel editor in Text mode and the formula editor in formula mode.
The autocomplete offers the full set of functions as you type. The complete catalog is grouped below by category.
String
| Function | Purpose | Example |
|---|---|---|
concat | Join any number of values into one string (numbers are converted to text, nulls are skipped), or any number of lists into one list | =concat('Order #', ${trigger_1.body.id}, ' for ', ${trigger_1.body.customer}) |
equalsIgnoreCase | Compare two strings ignoring case | =equalsIgnoreCase(${trigger_1.body.status}, 'active') |
format | Format a date/time (or apply String.format) with a pattern | =format(${trigger_1.body.createdDate}, 'yyyy-MM-dd') |
indexOf | First position of a substring | =indexOf(${trigger_1.body.email}, '@') |
lastIndexOf | Last position of a substring | =lastIndexOf(${trigger_1.body.path}, '/') |
length | Length of a string | =length(${trigger_1.body.title}) |
split | Split a string into a list by a delimiter | =split(${trigger_1.body.tags}, ',') |
substring | Extract part of a string | =substring(${step_1.code}, 0, 4) |
Date & time
| Function | Purpose | Example |
|---|---|---|
now | Current instant | =now() |
timestamp | Current Unix timestamp | =timestamp() |
atZone | Convert an instant to a zoned date/time | =atZone(${trigger_1.body.createdDate}, 'America/New_York') |
parseDate | Parse a string into a date | =parseDate(${trigger_1.body.date}) |
parseDateTime | Parse a string into a date/time | =parseDateTime(${trigger_1.body.timestamp}) |
plusDays … plusYears | Add time to a temporal value (plusHours, plusMinutes, plusSeconds, plusMillis, plusMicros, plusWeeks, plusMonths, plusYears) | =plusDays(${trigger_1.body.startDate}, 7) |
minusDays … minusYears | Subtract time from a temporal value (minusHours, minusMinutes, minusSeconds, minusMillis, minusMicros, minusWeeks, minusMonths, minusYears) | =minusMonths(${trigger_1.body.dueDate}, 1) |
List
| Function | Purpose | Example |
|---|---|---|
add | Add an element to a list | =add(${trigger_1.body.tags}, 'urgent') |
addAll | Append all elements of one list to another | =addAll(${step_1.items}, ${step_2.items}) |
contains | Whether a list contains an element (or a string a substring) | =contains(${trigger_1.body.tags}, 'vip') |
flatten | Flatten a list of lists into a single list | =flatten(${step_1.groups}) |
join | Join a list into a string with a separator | =join(', ', ${trigger_1.body.tags}) |
range | Build a list of integers between two bounds | =range(1, 10) |
remove | Remove an element from a list | =remove(${trigger_1.body.tags}, 'draft') |
set | Replace the element at an index | =set(${trigger_1.body.items}, 0, 'first') |
size | Number of elements in a list, array or map; -1 if null | =size(${trigger_1.body.items}) |
sort | Sort a list in natural order | =sort(${trigger_1.body.scores}) |
toMap | Build a map from a list of key/value pairs | =toMap(${step_1.entries}) |
Map
| Function | Purpose | Example |
|---|---|---|
put | Add or replace a key in a map | =put(${step_1.record}, 'status', 'done') |
putAll | Merge all entries of one map into another | =putAll(${step_1.record}, ${step_2.extra}) |
remove | Remove a key from a map | =remove(${step_1.record}, 'tempKey') |
Type conversion
| Function | Purpose | Example |
|---|---|---|
boolean | Convert a value to a boolean | =boolean(${trigger_1.body.enabled}) |
byte | Convert a value to a byte | =byte(${trigger_1.body.code}) |
char | Convert a value to a character | =char(${trigger_1.body.code}) |
short | Convert a value to a short | =short(${trigger_1.body.count}) |
int | Convert a value to an integer | =int(${trigger_1.body.quantity}) |
long | Convert a value to a long | =long(${trigger_1.body.id}) |
float | Convert a value to a float | =float(${trigger_1.body.price}) |
double | Convert a value to a double | =double(${trigger_1.body.amount}) |
Utility
| Function | Purpose | Example |
|---|---|---|
config | Read a configuration property value by name | =config('some.property') |
exists | true if a data pill resolves to a non-null value, for example the output of a step that may not have run. A missing value does not leave the formula unresolved. | =exists(${judge}) ? ${judge.answers.score} : 0 |
getOrDefault | The value of a data pill, or the default value when the pill does not resolve or is null. Works for boolean, number, string, list and map values. | =getOrDefault(${forceMistake}, false) |
uuid | Generate a random UUID (version 4) | =uuid() |
Operators
Expressions support the standard operators for arithmetic, comparison and conditional logic. You can combine them with data pills and functions.
| Operator | Purpose | Example |
|---|---|---|
+ - * / % | Arithmetic (+ also concatenates strings) | =${trigger_1.body.price} * 1.2 |
== != > >= < <= | Comparison | =${trigger_1.body.total} >= 100 |
&& || ! | Logical and / or / not | =${trigger_1.body.active} && ${trigger_1.body.total} > 0 |
? : | Ternary: one of two values depending on a condition | =${trigger_1.body.count} > 0 ? 'has items' : 'empty' |
?: | Elvis: use a default when the left side is null | =${trigger_1.body.name} ?: 'Anonymous' |
Lists of objects
To read one property from every object in a list, or keep only the objects that match a
condition, use projection and selection instead of a Loop. Inside the brackets, #this is the
current item.
| Syntax | Purpose | Example |
|---|---|---|
.![…] | Projection: a new list with one value per item | =${step_1.users}.![#this['email']] |
.?[…] | Selection: only the items that match a condition | =${step_1.users}.?[#this['active'] == true] |
.^[…] | First item that matches a condition | =${step_1.users}.^[#this['role'] == 'admin'] |
.$[…] | Last item that matches a condition | =${step_1.users}.$[#this['role'] == 'admin'] |
Chain them to filter first and then extract. For example,
=${step_1.users}.?[#this['active'] == true].![#this['email']] returns the emails of the active
users only.
email and #this['email'] both read the key from the current item, and an item without the key
gives null in the result. In ByteChef 0.34.0 and earlier, write #this['email']: there, the bare
form can leave the whole formula unevaluated when the first item in the list has no such key.
Switching between modes
Turning Formula on or off keeps the value whenever it can be carried over:
| Before | After switching | Result |
|---|---|---|
Constant 42 in a number field | Formula on | 42 (saved as =42) |
Text hello | Formula on | 'hello' |
| A single data pill | Formula on, or off again | The same pill |
Formula 42, true or 'hello' | Formula off | The constant 42, true or hello |
Text mixed with data pills, or a formula like concat(a, b) | Either way | The field is cleared |
Pressing Backspace in an empty formula also turns Formula off.
Which mode should I use?
- Text with a constant - the value is the same on every run.
- Text with data pills - the value comes from the trigger or an earlier step, optionally mixed with fixed text.
- Formula - the value must be computed or transformed before it is used.
How is this guide?
Last updated on