Rulesets
A Ruleset contains named WHEN/THEN rules. When a rule's conditions match, its actions change output or working data. Unlike a Decision Table, a Ruleset is designed for ordered actions such as setting values, incrementing totals, adding collection entries, removing matching entries, and clearing values.
When to use a Ruleset
Rulesets work well for enrichment, validation messages, product assembly, fee accumulation, and state changes. For example:
- add several reasons to a
referralReasonscollection; - accumulate risk points from independent rules;
- set a status and then clear an obsolete field;
- remove ineligible offers from a collection.
Use a Decision Table for a compact matrix, a Scorecard when point bands are the primary design, and a Workflow when actions span several HubItems or external systems.
Configure input and output
Select input and output Data Models in Settings. Enable auto-mapping only if the output should begin as a copy of compatible input fields. For mutation-heavy logic, it is often helpful for the output model to contain both the enriched object and explanatory fields such as matchedRules or reasons.
Example input:
{
"customer": {
"tier": "Gold",
"yearsActive": 6,
"overduePayments": 1
},
"order": {
"subtotal": 1250,
"items": [
{"sku": "A-10", "category": "Standard", "price": 500},
{"sku": "B-20", "category": "Restricted", "price": 750}
]
}
}
Example output fields:
{
"discountPercent": 0,
"riskPoints": 0,
"eligibleItems": [],
"messages": []
}
Create and order rules
Each rule has a name, priority, and enabled state. Names should describe the business event—Reward long-term Gold customer is better than Rule 4. Priority controls processing order. Use it deliberately when one rule depends on data written by another.
Disabling a rule preserves it for later use but prevents its actions from running. Do not use disabled rules as an undocumented release mechanism; create versions and tests for controlled changes.
Build the WHEN section
A rule can have one or more condition groups. Conditions within a group must satisfy that group's selected logic. Alternate groups let the rule match different acceptable scenarios.
For example, a loyalty rule could match:
Group 1
customer.tier equals "Gold"
AND customer.yearsActive is 5 or greater
OR Group 2
customer.tier equals "Platinum"
Keep groups small enough for a reviewer to explain aloud. If a condition becomes difficult to understand, calculate a named intermediate value earlier in a Workflow or Coding HubItem.
Collection-aware conditions can evaluate paths within an array. Confirm whether the intended meaning is “any entry matches,” “all entries match,” or an aggregate calculation by using the controls presented for that path and saving explicit tests.
Build the THEN section
Set
Set replaces a target value. Use a literal or a value drawn from available execution fields.
Set discountPercent to 0.10
Increment
Increment adds to a numeric target and is useful when independent rules contribute to a total.
Increment riskPoints by 15
Initialize the target through auto-map, the input contract, or an earlier rule so its starting value is unambiguous.
Append
Append adds a JSON-compatible value to a collection.
{
"code": "MANUAL_REVIEW",
"message": "Customer has an overdue payment"
}
Use the Rich Editor for object values and validate that the appended structure matches the collection's Data Model.
Remove
Remove deletes collection entries that match the configured condition. In the example order, a rule could remove items whose category equals Restricted before returning eligibleItems.
Clear
Clear removes a value or empties a collection as supported by the selected target. Use it when a state transition makes earlier data invalid—for example, clearing approvedAmount after setting decision to Declined.
Worked example: customer treatment
Create these rules:
| Priority | Rule | WHEN | THEN |
|---|---|---|---|
| 10 | Gold loyalty discount | Gold and active at least 5 years | Set discount to 10%; append loyalty message |
| 20 | Overdue-payment risk | At least one overdue payment | Increment risk by 15; append review message |
| 30 | Remove restricted products | Any item is Restricted | Remove matching entries from eligible items |
| 40 | Decline high risk | Risk points 30 or greater | Set decision to Declined; clear approved amount |
For the sample input, an illustrative response is:
{
"discountPercent": 0.1,
"riskPoints": 15,
"eligibleItems": [
{"sku": "A-10", "category": "Standard", "price": 500}
],
"messages": [
"Long-term Gold discount applied",
"Account requires payment-history review"
]
}
Dynamic values
When a value control offers field insertion, select an available path rather than typing it from memory. Templates such as {input.customer.tier} can incorporate execution data into a result. Keep user-facing messages free of sensitive fields and test how missing optional values render.
Test and debug
Create tests that prove both matching and non-matching behavior:
- Gold customer at 4 years and exactly 5 years;
- no overdue payments, one overdue payment, and several;
- empty item collection;
- all items restricted;
- several rules incrementing the same total;
- a disabled rule that must not change output.
Debug mode shows condition-group evaluation, rule order, and data mutations. If a later rule behaves unexpectedly, inspect the output immediately after every earlier rule.
Use in a workflow
A workflow Rule node can select a Ruleset and version. Map the source data into the Ruleset input and map the resulting enriched object or decisions onward. Deployment includes the Ruleset and its models as dependencies.
Common problems
| Problem | Resolution |
|---|---|
| Increment produces an unexpected value | Initialize the numeric target and inspect earlier matching rules |
| Append produces invalid output | Match the JSON object to the collection item model |
| Remove deletes too many entries | Narrow the collection condition and test mixed arrays |
| A rule never runs | Check enabled state, priority assumptions, condition types, and mapped input |
| Text template is blank | Referenced optional field is absent or the wrong path was selected |