Skip to content
← Back to Index

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

PromotionRuleReactor

Fields

FieldTypeDescription
ruleIdtextThe unique identifier of the rule
labeltext | { text -> text }The rule's label — either a plain string or a locale map for localized labels
activeFrominstantWhen the rule becomes active
activeToinstantWhen 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

© 2024 Hantera AB. All rights reserved.