JavaScript
JavaScript Plugin – Run Script
Summary (SEO Meta Description):
The JavaScript plugin in WeHub runs custom JavaScript code inside workflows.
Supports dynamic logic, transformations, and calculations using workflow inputs.
Overview
The JavaScript Plugin executes custom JavaScript code within workflows.
It enables flexible logic, data manipulation, and generation of new values where built-in processors are not enough.
This is useful for applying business rules, performing calculations, or creating custom transformations directly in the workflow.
⚙️ Action: Run Script
- Description: Executes a JavaScript snippet and returns computed results.
- Use Case: Perform string manipulations, numeric calculations, or generate unique identifiers dynamically.
Configuration Options:
| Field | Type | Description | 
|---|---|---|
| Label | String | Custom name for the node (e.g., "Double Invoice Amount"). | 
| Script | String | JavaScript code to execute. | 
| Inputs (Manual) | Object | Define inputs manually with Name and Type ( GUID,STRING,NUMBER,BOOL,CURRENT_TIME). | 
| Schema | Schema | Use schema to define input/output types instead of manual mode. | 
| Truncate Fields | Boolean | Toggle to truncate large outputs for performance. | 
| Truncate Level | Integer | Depth/length for truncation when enabled. | 
💡 Example Use Cases
- Healthcare: Convert patient names to uppercase before exporting to external systems.
- Finance: Multiply invoice amounts for currency conversion.
- Data Quality: Generate BOOLflags for validation checks.
- Custom IDs: Create GUIDs or timestamps for records dynamically.
FAQ
Q: What execution environment is used?
A: The script runs in a secure sandboxed JavaScript runtime inside WeHub.
Q: Can I use external libraries?
A: No. Only native JavaScript functions are supported.
Q: Can I return multiple values?
A: Yes. Return an object with multiple key-value pairs. Example:
Keywords: WeHub JavaScript Plugin, Run Script, workflow scripting, custom logic, automation