Skip to main content

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:

FieldTypeDescription
LabelStringCustom name for the node (e.g., "Double Invoice Amount").
ScriptStringJavaScript code to execute.
Inputs (Manual)ObjectDefine inputs manually with Name and Type (GUID, STRING, NUMBER, BOOL, CURRENT_TIME).
SchemaSchemaUse schema to define input/output types instead of manual mode.
Truncate FieldsBooleanToggle to truncate large outputs for performance.
Truncate LevelIntegerDepth/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 BOOL flags 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