principianteInicio fácil

Custom Code

This template describes the Custom Code Rule Flow, a functional example designed to demonstrate how custom scripting can be integrated into a decision workflow within the DecisionRules environment.

DecisionRules

David Škarka

Template author

The primary objective of this Rule Flow is to demonstrate the usage of the Custom Code node. It serves as a practical template for executing custom JavaScript logic within a flow to perform calculations that may exceed the scope of standard nodes. 

Specifically, this flow takes two numerical inputs and calculates their product.

Solution Components
The workflow sequences the logic through the following stages:
  • Start Node: The entry point that receives the input data.
  • Custom Code Node (code): This is the core engine of the flow. It executes a JavaScript snippet to process the data:
    • Calculation: It reads value1 and value2 from the workflow input and multiplies them.
    • Output Assignment: It assigns the result to workflow.output.product.
    • Logging: It logs the multiplication result to the console for debugging purposes.
  • End Node: Finalizes the execution and returns the calculated product to the requester.

Use This Template To Learn How To:
  • Implement Custom JavaScript: How to use the Custom Code node to write and execute scripts directly within a workflow.
  • Access Workflow Data: How to programmatically reference workflow.input and set workflow.output within a script.
  • How to propagate a script result to the flow
Check iconA checkmark inside a circle signifying "yes"Minus iconA minus inside a circle signifying "no"PROS IconA plus symbol representing positive aspects or benefits.CONS IconA minus symbol representing negative aspects or drawbacks.

More Templates

See Other Templates

servicios financierossugerido

Pruebas A/B

Descubra una forma sencilla de asignar un grupo de prueba para realizar pruebas A/B en sus decisiones.

Explore
servicios financierossugerido

Precios basados ​​en el riesgo

Descubra una forma sencilla de aplicar una matriz de precios basada en riesgo adecuada en función del tipo de cliente.

Explore
servicios financierossugerido

Normas de elegibilidad y política

Descubra una forma sencilla de definir y ejecutar varios conjuntos de reglas y obtener el resultado de la decisión final.

Explore