Fluent Commerce Logo
Docs

Rule Parameters

Topic

Author:

Fluent Commerce

Changed on:

28 Sept 2023

Overview

Rule Parameters, also known as properties or props, and the configuration time inputs to the Rule.Rule Parameters should be considered always required. Optional inputs to a Rule should usually be managed via Event Attributes.

Rule Parameters

Author:

Fluent Commerce

Changed on:

28 Sept 2023

Overview

Rule Parameters, also known as properties or props, and the configuration time inputs to the Rule.Rule Parameters should be considered always required. Optional inputs to a Rule should usually be managed via Event Attributes.

Key points

  • There are 4 Parameter types available to declare on Rules:
    • String Parameters
    • Integer Parameters
    • Enum Parameters
    • Time Period Parameters
  • Also, on this page, see how to implement Multi-value Parameters

String Parameters

The `@ParamString` Annotation defines a Parameter for the Rule of type `String`.It contains 3 properties:
  • `name` - the Name of the Parameter. This is Required.
  • `description` - the Description of the Parameters. This is Required.
  • `defaultValue` - this is the Default Value of the Parameter. This is Optional.
Property NameDescriptionRequiredDefault Value
`name`The name of the rule parameter. This becomes the key name used in the `props` construct of the Workflow JSON configuration.Y
`description`A helpful text describing the parameter. This is important meta data for use within the Workflow Builder UI and the Plugin GET API.Y
`defaultValue`A default value if the parameter is not set.N

Integer Parameters

The `@ParamInteger` Annotation defines a Parameter for the Rule of type `Integer`.It contains 5 properties:
Property NameDescriptionRequiredDefault Value
`name`The name of the rule parameter. This becomes the key name used in the `props` construct of the Workflow JSON configuration.Y
`description`A helpful text describing the parameter. This is important meta data for use within the Workflow Builder UI and the Plugin GET API.Y
`min`The minimum value allowed to be entered for the rule parameter.N`Integer.MIN_VALUE`
`max`The maximum value allowed to be entered for the rule parameter.N`Integer.MAX_VALUE`
`defaultValue`A default value if the parameter is not set.N`Integer.MIN_VALUE`

Enum Parameters

The `@ParamEnum` Annotation defines a Parameter for the Rule of type `Enum`. This is useful for circumstances where only a specific set of values is acceptable as an input. There is however a downside though. If ever the list of parameter values needs to be changed or extended, it would require a code change, so use this only when this is not likely to be the case. If you need a list of parameter values for a Rule, but it needs to remain configurable at runtime, this can be achieved using Settings. See Multi-value Parameters for more information.It contains 4 properties:
Property NameDescriptionRequiredDefault Value
`name`The name of the rule parameter. This becomes the key name used in the `props` construct of the Workflow JSON configuration.Y
`description`A helpful text describing the parameter. This is important meta data for use within the Workflow Builder UI and the Plugin GET API.Y
`options`This is the Enum class providing the available options to be selected.Y
`defaultValue`A default value if the parameter is not set.N

Time Period Parameters

The `@ParamTimePeriod` Annotation defines a Parameter for the Rule of type `Integer` signifying a duration in seconds.It contains 5 properties:
Property NameDescriptionRequiredDefault Value
`name`The name of the rule parameter. This becomes the key name used in the `props` construct of the Workflow JSON configuration.Y
`description`A helpful text describing the parameter. This is important meta data for use within the Workflow Builder UI and the Plugin GET API.Y
`min`The minimum value allowed to be entered for the rule parameter.N`Integer.MIN_VALUE`
`max`The maximum value allowed to be entered for the rule parameter.N`Integer.MAX_VALUE`
`defaultValue`A default value if the parameter is not set.N`Integer.MIN_VALUE`

Multi-value Parameters

Rules can receive complex objects, such as Arrays or a JSON object, as Parameter inputs.For example, you may need to receive an object containing a number of fields, or an array of Strings, Integers, or any other Objects.Typically, we recommend using a standard String Parameter which receives a Setting name which references a Setting in the platform.It is up to the Rule logic to handle the correct parsing of this complex type.For example, let's say you want to provide a list of Virtual Catalogue References for querying Virtual Positions within the Rule. You could create a Rule Parameter for the Setting Name, such as `acme.sourcing.multi-channel.catalogues`, which expects a JSON value such as the following:
Fluent Commerce

Fluent Commerce