Skip to content

Formula node

Every step of a workflow is a formula node. What the node does is written in its node file: a list of statements that runs top to bottom on the rows the node receives. One statement loads a file, the next renames a column, the last filters out bad rows. There is no separate node type for loading, saving, calling an API, or asking AI; each of those is a statement.

Besides formula nodes, a canvas holds only furniture: panels, sticky notes, and marker strokes. They organise the canvas and do not run.

A node’s file lives beside the workflow, in a folder named after it: <workflow name>-scripts/<node id>.ffl. For orders.wf.json that is orders-scripts/. Open it from the node, or in Fontana Files as Source.

Paths inside a node file are relative to the node file. ../orders.csv is the file that sits beside the workflow.

fromFile("../orders.csv")
setProp("Order ID", prop("id"))
setProp("Amount", prop("amount"))
setType("Amount", "number")
keepProps("Order ID", "Amount")
filter(prop("Amount") > 0)

The node editor opens on statement cards for that file. Press Code on the left of the header to edit the statements as Formula text. Click an English sentence on a card (or a Keep column chip) to change that step in place, then Process.

A field that takes a credential holds a workspace secret as secret("NAME"), picked by name from a padlock chip; the value never enters the file.

On the canvas, a node sums up its file as coloured strips, one under the other, in the order of the statements. Each strip uses the Form card colours: loading and saving amber, AI purple, changes to the rows and columns blue, checks green, styling pink.

  • A verb gets a strip of its own with its icon and what it works on: the file it loads or saves, the AI instructions and the columns they return, or the query language. A saved file links to the file the last run wrote.
  • Statements that set or retype columns, one after another, share one strip: “4 columns” and the first column names.
  • Other statements of one kind in a row share one counted strip, such as “3 transformations” or “2 validations”.

A node with a single statement shows it across the whole card instead. A node that only loads a file shows the file type large, the file name under it and, once it has run, its row and column counts. When you zoom out, nodes draw as plain squares.

The node picker offers each common step as a preset, which starts the node file with that statement:

Preset Starts with
Load a file fromFile
Save to a file toFile
Download from the web fromWeb
Call an API fromApi / toApi
Run a GraphQL query fromGraphql
Receive an email fromEmail
Send an email toEmail
Receive a request fromRequest
Ask AI per row fromAi
Render a template fromTemplate
Run a query fromQuery
Run a script fromScript
Extract a region subgrid
Set a column type setType
Set the row key rowKey

Each preset is coloured by what its statement does, in the same colours as the Form cards: imports and exports amber, AI purple, and changes to the rows blue.

While a node’s editor is open, double-click a preset, or drag it onto the editor, to add its statement to the end of that node’s file. Drag it onto the canvas instead to make a new node. Undo removes the added statement. If the statement cannot follow the ones already there, it is still added, and the editor shows the problem on that statement.

A node file holds three kinds of statement: verbs that read or write the world, shaping statements that cut and name the rows, and formula statements such as setProp, filter, appendRows, groupBy, and raiseException. See Formula for the formula language.

One node file never reads and writes the same path. To update a file, read it in one node and write it in a node downstream.

fromFile(path) reads a Workspace file into rows. Options:

Option Use
.sheet(...) Pick one sheet of a workbook
.headerRow(false) Keep the first row as data instead of column names
.delimiter(...) Delimited text with a custom separator
.encoding(...) Text encoding of the file
.skipEmptyRows(...) Keep or drop blank rows
.recordFormat(...) Delimited or fixed-width records
.fieldWidths(...) Field widths for fixed-width records
.fieldNames(...) Column names for fixed-width records

See Supported formats for what each file type loads as.

  • toFile(path) writes the rows to a Workspace file. The extension picks the format: csv, tsv, psv, xls, xlsx, json, xml, txt, or fix.
  • toEmail(address).subject(...) sends the rows as an email.
  • eachRow().toApi(url).method("POST") calls an API once per row.
  • toGraphql(...) sends rows to a GraphQL endpoint.

See Call REST and GraphQL APIs and Send and receive email for every option, with examples.

  • fromEmail() reads the email that started the run. Give the node an inbound email trigger in its settings; the node then has its own inbound address on your tenant mail domain, and each email to it starts a run. The rows are one per message with from, sent, subject, body, to, cc, messageId, and attachments. Your platform team enables inbound email and the tenant mail domain for the deployment (see Fontana CLI).
  • fromRequest() reads the inbound REST or GraphQL request that started the run.
  • fromApi(url) reads rows from a REST API.
  • fromGraphql(url, query).records(path) runs a GraphQL query and takes the rows at path in the answer.
  • See Call REST and GraphQL APIs for the options of fromApi and fromGraphql, signing in, and per-row calls.
  • fromWeb(url).folder(path) downloads from the web into a Workspace folder. Add .git() for a git repository or .sitemap() to follow a site’s sitemap. An Azure DevOps project URL takes .workItems(), .wiki(), or .repos(). Narrow what is fetched with .include(...) and .exclude(...), and sign in with .auth(bearer(secret("T"))) or .auth(basic("", secret("T"))), where T is a Workspace secret.
  • eachRow().fromAi(prompt).returns(name, type) asks AI once per row and writes the answer to a typed column.
  • fromTemplate(jinja) renders a Jinja template over the rows; put eachRow() in front to render one per row.
  • fromQuery(text, "sql") runs a query over the rows, which it reads as the table rows; .tables(...) names other tables. "jsonata" and "jsonpath" work the same way.
  • fromScript(code, "js") runs a script over the rows.

See Ask AI in a workflow and Templates, queries, and scripts for worked examples.

  • inputs("name").subgrid(table, "Sheet!B4:H").headerRows(n) cuts a region out of a sheet and uses its first n rows as column names.
  • setProp(name, value) computes or renames one column: a new name adds a column, an existing name replaces it. Statements run in order, each reading the row as the statements before it left it, so a setProp that reads a column an earlier setProp replaced with another value is an error: write it first, or go through a temporary column. A dotted name ("bond.isin") is one column that JSON output nests; CSV keeps the dotted name.
  • setType(name, "number" | "date" | "text" | "boolean") converts that column’s values to the type from that statement on. A value that cannot convert fails the run.
  • keepProps(name, …) keeps only those columns, in that order, and drops every other column. Later statements read only those names.
  • rowKey(col, …) names the columns that make a row the same row across runs. Exception management matches tickets by this key.

Workflows used to be built from one node type per kind of step. Each of those steps is now a statement in a formula node:

Was Now
File Input fromFile(path)
Static Data A CSV file in the Workspace, read with fromFile
Data Storage fromFile + appendRows, then a separate node with toFile
Save File toFile(path)
Email Import fromEmail() with an inbound email trigger
Email Export toEmail(address).subject(...)
REST Input, GraphQL Input fromRequest()
REST API fromApi(url), or eachRow().toApi(url).method("POST")
GraphQL API fromGraphql(url, query).records(path) or toGraphql(...)
Download Files fromWeb(url).folder(path)
AI eachRow().fromAi(prompt).returns(name, type)
Template (Jinja) fromTemplate(jinja)
Query fromQuery(text, "sql" | "jsonata" | "jsonpath")
Compute fromScript(code, "js")
Subgrid subgrid(table, "Sheet!B4:H").headerRows(n)
Schema setProp, setType, and keepProps for the columns, rowKey(...) for the row identity key
Filter filter(...)
Operation, Default Formula statements in the node file
Data Connector Not available yet

Data connectors and stores are not available as statements yet.

One wire into a node is that node’s rows. Several wires are named tables, each named by its wire’s handle, and the node reads one with inputs().prop("<handle>"). Nothing merges several wires by itself: write the merge as statements, for example with appendRows. See Wires and named tables.

A node that writes a file or sends an email carries this trigger condition when you add it:

input().exceptions().prop("warning") == 0 and input().exceptions().prop("error") == 0

It exports only when no node upstream raised a warning or error exception in that build. Edit the condition on the node, or set it to always to export whatever arrives. See How a node runs.

Workflows that still hold a retired node type

Section titled “Workflows that still hold a retired node type”

A workflow file that still holds one of the retired node types does not open. Flow refuses it and names each such node:

node type `<type>` is retired: rebuild this step as a `formula` node

Rebuild each named step as a formula node using the table above, then open the workflow again.