rule
Keyword
{ ruleId: text label: text | { text -> text } activeFrom: instant activeTo: instant } The rule keyword provides access to metadata about the currently executing rule. It returns a record with the rule's identity, label, and activation window.
rule is a symbol — use it directly without parentheses.
Availability
| Promotion | Rule | Reactor |
|---|---|---|
| ✓ |
Fields
| Field | Type | Description |
|---|---|---|
ruleId | text | The unique identifier of the rule |
label | text | { text -> text } | The rule's label — either a plain string or a locale map for localized labels |
activeFrom | instant | When the rule becomes active |
activeTo | instant | When the rule stops being active |
Examples
Access rule metadata
filtrera
param input: OnOrderCreated
from [{
effect = 'orderCommand'
type = 'createPromotion'
componentId = 'free-shipping'
promotionGroup = 'shipping'
description = rule.label
parameters = { threshold = '500' }
}]Use localized label
When the rule's label is a locale map, you can resolve it using the order's locale:
filtrera
param input: OnOrderCreated
let description = rule.label match
text |> rule.label
|> rule.label->input.order.locale
from [{
effect = 'orderCommand'
type = 'createPromotion'
componentId = 'volume-discount'
promotionGroup = 'campaign'
description = description
}]See Also
- Rules Overview — introduction to rules
- Rule Hooks — available lifecycle hooks
- Rule Effects — available effects