Workflow Engine in Depth - Custom Code

The Custom Code Workflow Node in DecisionRules provides users with the flexibility to integrate their own JavaScript code within a decision-making process. This feature allows for enhanced control, customization, and logic that extends beyond predefined rules or workflows.

Workflow Nodes in general

A node can be considered a fundamental building block of a workflow. The workflow provides a variety of nodes to support the implementation of both core business processes and supplementary functions. All available nodes are organized in the palette located on the right side of the workflow editor. These nodes are grouped into five main categories:

  • Basic
  • Decision Rules
  • Array Functions
  • Data & Integrations
  • Advanced

Each category contains specialized nodes, you can find more details about this in our documentation. 

In this article, we will focus on exploring the Custom Code Node in detail.

Custom Code Node

The Custom Code Node enables users to insert and execute their custom JavaScript code. By using this node, users can create specialized logic that isn’t directly supported by other nodes, enabling them to craft more complex or specific decision-making processes.

Custom code nodes can handle various tasks like data transformations, integrating third-party services, or adding logic that is unique to your specific use case.

Key Features of the Custom Code Node

  • JavaScript Integration - This allows developers to include complex operations or apply business logic that standard workflow nodes might not support.
  • Seamless Workflow Integration - Custom Code Node can take the output of previous nodes, apply custom logic, and pass the modified or calculated results to subsequent nodes.
  • Dynamic Inputs and Outputs - Users can use any variable as the Custom Code Node’s input, including variables that have been previously created during the workflow runtime. 

Common Use Cases

  • Data Transformation - In workflows, you may need to transform or reformat data before passing it to another node. The Custom Code Node is perfect for applying specific data transformations that may not be covered by default nodes.
  • Custom Validation Logic - Users can implement their own validation rules. For example, if you need to validate incoming data against a proprietary or unique set of business rules, the Custom Code Node allows you to implement those checks directly.
  • Advanced Math or Calculations - While the core system offers many standard functions, custom code allows creating complex mathematical operations or algorithmic logic to be added directly into your workflow.

Conclusions

The Custom Code Workflow Node in DecisionRules is a powerful tool that allows users to introduce flexibility and customization within their workflows. By enabling the use of JavaScript, it extends the system's functionality, making it possible to incorporate custom logic, complex transformations, and third-party integrations. Proper use of this node can enhance the decision-making process, providing solutions that are tailored to unique business needs. However, careful planning, testing, and optimization are crucial to ensure the effectiveness and reliability of custom code in production workflows.

More reading