chatleadr Docs

The Function Node

Writes one variable in the middle of a workflow, so a later node can use a value the workflow did not collect directly. Operation Type chooses how that value is built.

Format the dateFunctionFunction Configured Successfully SuccessError
A Function node running custom JavaScript. The preview reports whether the code compiled, not what it does.
Format the date Operation Type Run Custom JS (ES5) JavaScript Code var raw = flow.Lookup ? flow.Lookup.eta : '';var d = new Date(raw);setExport("eta", d.getDate() + '/' + (d.getMonth()+1)); Variables are read-only here.Export downstream with setExport("name", value). Done
The first control on the panel is Operation Type. It is shown here on Run Custom JS (ES5); choosing Update / Override Data replaces the code editor with a variable and a text box.

Assemble a Value From Variables You Already Have#

Set Operation Type to Update / Override Data. Two settings follow:

  • Variable to Update, chosen from the variables in scope at this point in the workflow.
  • Value (Text / Template), the text to write, with {{variables}} interpolated into it.

Reach for this first. It needs no code and cannot hit an execution limit. A full name assembled from a first name and a surname, a reference line built from an order number and a date, and a stand-in value for a field the visitor left blank are each one entry in that box.

To change a value rather than assemble one, converting a date to another format or adding up a list, set Operation Type to Run Custom JS (ES5). See custom code in a workflow.

Connect the Error Port or the Run Ends Silently#

In Update / Override Data mode the node always leaves through Success. A {{variable}} that resolves to nothing is written as the literal characters you typed rather than failing, so check the value in a Decision node where a later step depends on it being filled. Run Custom JS (ES5) leaves through Error when it throws or runs too long, and a port with nothing wired to it ends the run there. Nothing records a failure, and if the workflow has said nothing in that turn the assistant answers on its own.

Read the New Value in Later Nodes#

The value is stored under the name you chose in Variable to Update rather than under this node's label, and every node downstream of this one can read it.