Function
Execute custom JavaScript with full access to workflow data — the most powerful scripting node in BizFirst for complex transformations, business logic, and data processing.
No authentication required. The Function node executes JavaScript locally within the BizFirst workflow engine. No external service credentials are needed.
Function vs CodeExecute
BizFirst provides two scripting nodes. Understanding the difference helps you choose the right one:
| Feature | Function | CodeExecute |
|---|---|---|
| Engine | Sandboxed V8 execution (full JavaScript runtime) | Jint (embedded lightweight JS engine) |
| Best for | Complex logic, transformations, multi-step processing, custom business rules | Simple expressions, quick value transformations, inline calculations |
| Workflow data access | Full access via context object — all node outputs, variables, and input data | Limited — primarily for single expression evaluation |
| SandboxMode | Configurable — true (restricted) or false (broader access) | Always sandboxed |
| Return value | Explicit return statement or last expression value | Last expression value |
| Error handling | Routes to error port on exception or timeout | Routes to error port on exception |
Security Model
The Function node runs in a sandboxed V8 context. The security level is controlled by SandboxMode:
SandboxMode = true (Default — Recommended)
- No access to
fetch,XMLHttpRequest, or network calls - No access to
require,import, or Node.js modules - No access to the file system (
fs,path) - No access to
process,global, or environment variables - Standard JavaScript globals available:
JSON,Math,Date,Array,Object,String,RegExp,parseInt,parseFloat, etc. - Full access to workflow data via the
contextobject
SandboxMode = false (Trusted Contexts Only)
- Broader globals available — use only in self-hosted BizFirst deployments where all workflow authors are trusted
- May allow network calls, module loading, and environment access depending on platform configuration
- Never use
SandboxMode=falsein multi-tenant environments where workflows are authored by external parties
Output Ports
| Port | Description |
|---|---|
success | Script executed without errors. Output contains the return value of the script plus execution metadata. |
error | Script threw an unhandled exception, the timeout was exceeded, or a syntax error was detected. Includes errorCode, message, and stack trace. |
Use Cases
- Complex JSON transformations — reshape, flatten, or restructure data from upstream nodes before passing to APIs
- Custom business logic — implement pricing engines, discount calculators, eligibility rules, or scoring algorithms
- Data validation — run multi-field validation rules and return structured error arrays
- String processing — regex extraction, template rendering, slug generation, or text normalisation
- Array manipulation — filter, group, sort, deduplicate, or aggregate collections from Loop or CollectionOperation outputs
In This Guide
Configuration
Script, Timeout, SandboxMode properties — plus full documentation of the context object available inside scripts.
Input & Output
How to access input data and workflow state in scripts, return value handling, and error port behaviour.
Examples
Four examples: JSON transformation, pricing engine, multi-rule validation, and regex extraction.