truquesavançado

Regra de chamada a partir do script

Este exemplo mostra como chamar facilmente qualquer regra a partir de uma Regra de Script, o que pode ser útil, por exemplo, na criação de uma orquestração complexa.

DecisionRules

Leos Rehacek

Template author

This Decision Flow demonstrates the capability to invoke a specific rule from within a Scripting Rule programmatically. Instead of a Decision Flow, this orchestration uses a script to pass input data to a child rule (a Decision Table) and retrieve the results for further processing or output. This pattern is useful for building complex orchestrations where rule execution may depend on logic defined in JavaScript.

Solution components
The solution consists of two primary rules contained within the "Call Rule From Script" folder:
  • Child Table: A Decision Table that functions as a lookup engine, assigning product details based on a category code. This table defines the business logic for mapping category codes to specific banking products. It evaluates the Code (mapped from categoryCode) to determine the Product Name and Product Code.
    • Input: The table accepts a Code (e.g., "OA" or "SA").
    • Logic:
      • If the Code is OA, it returns "Regular Account" (OAO1).
      • If the Code is SA, it can return "Saving Account Standard" (SAO1) or "Saving Account Premium" (SAO2).
    • Output: It returns the productName and productCode.
  • Call Rule From Script: A Scripting Rule that acts as the orchestrator. It accepts input, calls the decision table using its unique alias, and outputs the matched rows.  It does not contain a decision table itself but uses JavaScript to leverage the Decision Rules engine (DR).
    • Logic:
      • It utilizes the DR.solve function to target the child rule by its alias.
      • It passes the input variable categoryCode to the child rule.
      • It uses a standard solver strategy (SolverStrategy.STANDARD).
    • Result: The script logs the result and maps the output of the Decision Table (tableResult) to the script's output variable matchedRows.
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

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.

Explore
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.

Explore
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.

Explore