Lua scripts and data access
Put Lua in CDATA to preserve comparison operators and text containing XML characters. This script returns a count and label as its output.
<workflow>
<nodes>
<script id="prepare" type="lua"><![CDATA[return { count = 3, label = 'Ready' }]]></script>
</nodes>
<edges/>
</workflow>Use the Lua reference for available functions. Queries, file operations and connected devices require the execution identity to have the relevant permissions. Bind query values instead of joining user input into SQL. Keep secrets in configured connections rather than workflow source. A timeout or retry can repeat an external operation; use a stable request identifier where the destination supports one.
A Lua workflow chunk receives its argument through local input = .... A root script receives the run input object directly, so a run input { "quantity": 500 } is available as input.quantity. The stored root step observation retains the executor envelope { "input": { "quantity": 500 } }.
For a script connected after a node with ID load-order, the chunk argument contains both the original run inputs under input.input and that predecessor's result under input["load-order"]. Read the order ID from input["load-order"].id and the requested quantity from input.input.quantity.
Connect the producing node to the script; referring to its ID in Lua does not establish a dependency.
Published platform manual · revision 007981d44274