Fluent Commerce Logo
Docs

Rules SDK - Event Attributes

Essential knowledgeCore knowledge to understand Fluent Commerce

Author:

Fluent Commerce

Changed on:

19 Jan 2024

Overview

The `@EventAttribute` Annotation declares the Event Attributes the Rule requires from the Event.

Key points

  • Event Attributes
It contains 2 properties:
  • `name` - the Name of the Event Attribute.
  • `type` - the Type of the Event Attribute.
`@EventAttribute(name = "EventAttribute1", type = "STRING")
`
Event Attribute Types include:
  • STRING (default)
  • INTEGER
  • BOOLEAN
The Event Attribute Type is used to provide configuration guidance to the Workflow, which is used to drive User Actions on the front end.When using a complex event attribute type such as a JSON object, it is helpful to provide a meaningful name for that Type to the workflow configurators and frontend developers.Currently, the Rules SDK only supports a limited set of Attribute Type names, and therefore the JSON attribute must use the default type of `STRING`.The Rule code can cast the event attribute into a specific type, such as `StockReserveDetails` below:StockReserveDetails Class:`
`
StockReservationRequest Rule:When declaring a User Action on a Ruleset using this rule, the Event Attribute Type should now be declared as follows:StockReservation Ruleset & User Action: