Author:
Fluent Commerce
Changed on:
28 Sept 2023
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.
Author:
Fluent Commerce
Changed on:
28 Sept 2023
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.
The
`@ParamString`
`String`
It contains 3 properties:
`name`
`description`
`defaultValue`
Property Name | Description | Required | Default Value |
| The name of the rule parameter. This becomes the key name used in the
| Y | |
| A helpful text describing the parameter. This is important meta data for use within the Workflow Builder UI and the Plugin GET API. | Y | |
| A default value if the parameter is not set. | N |
1@ParamString(name = "productCatalogueRef", description = "The reference to the Product Catalogue", defaultValue = "FCRG:PC:MASTER")
Language: java
Name: Here is an example declaration of @ParamString:
Description:
[Warning: empty required content area]The
`@ParamInteger`
`Integer`
It contains 5 properties:
Property Name | Description | Required | Default Value |
| The name of the rule parameter. This becomes the key name used in the
| Y | |
| A helpful text describing the parameter. This is important meta data for use within the Workflow Builder UI and the Plugin GET API. | Y | |
| The minimum value allowed to be entered for the rule parameter. | N |
|
| The maximum value allowed to be entered for the rule parameter. | N |
|
| A default value if the parameter is not set. | N |
|
1@ParamInteger(name = "ParamInt1", description = "Parameter Int 1", min = 0, max = 9, defaultValue = 0)
Language: java
Name: Here is an example declaration of @ParamInteger:
Description:
[Warning: empty required content area]The
`@ParamEnum`
`Enum`
It contains 4 properties:
Property Name | Description | Required | Default Value |
| The name of the rule parameter. This becomes the key name used in the
| Y | |
| A helpful text describing the parameter. This is important meta data for use within the Workflow Builder UI and the Plugin GET API. | Y | |
| This is the Enum class providing the available options to be selected. | Y | |
| A default value if the parameter is not set. | N |
1// Define an Enum use either in the same Java file as the Rule, or in a separate file within your Plugin Project:
2enum YesNoEnum {
3 YES, NO
4}
5
6@ParamEnum(name = "DoSomething", description = "Select YES or NO to doing something", options = YesNoEnum.class, defaultValue = YesNoEnum.YES)
Language: java
Name: Here is an example declaration of @ParamEnum:
Description:
[Warning: empty required content area]The
`@ParamTimePeriod`
`Integer`
It contains 5 properties:
Property Name | Description | Required | Default Value |
| The name of the rule parameter. This becomes the key name used in the
| Y | |
| A helpful text describing the parameter. This is important meta data for use within the Workflow Builder UI and the Plugin GET API. | Y | |
| The minimum value allowed to be entered for the rule parameter. | N |
|
| The maximum value allowed to be entered for the rule parameter. | N |
|
| A default value if the parameter is not set. | N |
|
1@ParamTimePeriod(name = "delaySeconds", description = "Delay value in seconds", min = 0, max = 9, defaultValue = 5)
Language: java
Name: Here is an example declaration of @ParamTimePeriod:
Description:
[Warning: empty required content area]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`
1{
2 "virtualCatalogueRefs": [
3 "VC:ATS:ECOMMERCE",
4 "VC:ATS:MARKETPLACE"
5 ]
6}
Language: json
Name: Example
Description:
[Warning: empty required content area]1@RuleInfo(name = "FulfilFromMultiSources", description = "Fulfils from any available positions in multiple Virtual Catalogues configured in setting {cataloguesSetting}")
2@ParamString(name = "cataloguesSetting", description = "The Setting name holding the list of Virtual Catalogue References to include in the search")
3public class FulfilFromMultiChannelSources implements Rule {
4 @Override
5 public <C extends Context> void run(C context) {
6 String cataloguesSetting = context.getProp("cataloguesSetting");
7
8 // Note: the `getSetting` method is not provided, but encapsulates querying the GraphQL Settings API.
9 Optional<VirtualCataloguesSetting> setting = getSetting(context, cataloguesSetting).as(VirtualCataloguesSetting.class);
10
11 if(setting.isPresent()) {
12 // Continue Sourcing...
13 } else {
14 // Note: the `logOnce` method is not provided, but encapsulates the `context.action().log()` action.
15 logOnce(context, VirtualCataloguesSetting.class, "No Catalogues config found at '%s'", cataloguesSetting);
16 }
17 }
18
19 @Data
20 @AllArgsConstructor
21 private static final class VirtualCataloguesSetting {
22 String[] virtualCatalogueRefs;
23 }
24}
Language: java
Name: The Rule could be implemented as follows:
Description:
[Warning: empty required content area]Copyright © 2024 Fluent Retail Pty Ltd (trading as Fluent Commerce). All rights reserved. No materials on this docs.fluentcommerce.com site may be used in any way and/or for any purpose without prior written authorisation from Fluent Commerce. Current customers and partners shall use these materials strictly in accordance with the terms and conditions of their written agreements with Fluent Commerce or its affiliates.