FlexiRule Docs
Sub-Rule
Run an exposed sub-rule as a reusable module within your visual rule flow.
Sub-Rule Action#
The Sub-Rule action lets you run another rule—exposed as a sub-rule—directly inside your main rule flow, allowing you to reuse modular logic across multiple rules.
1. What is it?#
A Sub-Rule block executes a separate rule flow and passes variables back and forth. This lets you build reusable logic modules (like standard approval workflows or credit checks) once and call them from multiple rules.
Main Rule ──→ Sub-Rule ("Calculate Customer Risk") ──→ Next Action (Check Risk Score)
2. When to Use#
Use a Sub-Rule action when you need to:
- Reuse multi-step verification routines across different DocTypes or trigger events.
- Break down complex rules into clean, modular sub-flows.
- Standardize business calculations (e.g., standard credit scoring or discount rules).
3. How to Configure#
- Add the Action: Add a Sub-Rule block to your visual canvas.
- Select Target Sub-Rule:
- Choose from the list of rules exposed as sub-rules.
- Map Input Variables:
- Map values from your main rule to the input variables expected by the sub-rule using the Smart Value Selector.
- Set Output Variable:
- Enter a variable name (e.g.,
risk_result) to capture the sub-rule’s returned output in@vars.
- Enter a variable name (e.g.,
- Connect Outbound Branch: Connect the Sub-Rule block’s output port to the next action node.
4. UI Configuration Options#
| Option | Description |
|---|---|
| Sub-Rule | Select target rule (must have Exposed as Sub-Rule enabled in its rule configuration). |
| Input Mappings | Map main rule fields/variables to sub-rule parameters using the Smart Value Selector. |
| Output Variable | Variable name in @vars where sub-rule output results will be stored. |
5. Practical Example#
Scenario: Run Standard Customer Risk Scoring Sub-Rule#
- Sub-Rule Block Configuration:
- Sub-Rule: Select
"Calculate Customer Risk Score". - Input Mapping: Map
Customer→@doc.customerusing Smart Value Selector. - Output Variable: Enter
risk_score_result.
- Sub-Rule: Select
- Next Action (Check):
- Add a Check block following the sub-rule.
- Condition:
@vars.risk_score_result.score > 80 - True Branch: Route to manager review notification.
6. Common Mistakes#
- Sub-Rule Not Exposed: Trying to select a rule that does not have Exposed as Sub-Rule enabled in its settings.
- Circular Sub-Rule Calls: Creating a loop where Rule A calls Sub-Rule B, which calls Sub-Rule A.
- Missing Input Mappings: Forgetting to map mandatory input variables required by the sub-rule.
7. Related Features#
- Rule Configuration: Learn how to expose a rule as a reusable sub-rule.
- Advanced Process: Execute pre-built code operations rather than visual sub-rules.
Was this page helpful?