inicianteInício 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.
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:
Use This Template To Learn How To:
- 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
More Templates
See Other Templates
serviços financeirossugerido
Teste A/B
Descubra uma maneira simples de atribuir um grupo de teste para realizar testes A/B em suas decisões.
serviços financeirossugerido
Precificação baseada em risco
Descubra uma maneira simples de aplicar uma matriz de precificação baseada em risco adequada ao tipo de cliente.
serviços financeirossugerido
Critérios de Elegibilidade e Regras da Política
Descubra uma maneira simples de definir e executar vários conjuntos de regras e obter o resultado da decisão final.