Builds a points rule type, which decides whether a sales record earns points and how many. Obtained from pointsRuleTypeBuilder on the controller mappings. The include function filters which records the rule applies to, the process function returns the points to award, and the fields are the settings an administrator fills in when adding the rule to a points programme. Call build to register the rule type.

Group: Builders


Methods

build()

Returns: JsPointsRuleType

Creates the points rule type from the configured values and registers it against this app, initialising it against the app's engine. The type is still created and returned once the engine has initialised, but it is no longer registered.

includeFn(String s)

Returns: PointsRuleTypeBuilder

Names the function that decides whether a given sales record is covered by this rule. It is called with the record, the rule parameters, the allocation source and the points recipient, and should return a boolean. When no function is set every record is included.

ParameterDescription
sname of the global JavaScript function that filters records

processFn(String s)

Returns: PointsRuleTypeBuilder

Names the function that calculates the points to award for a record. It is called with the record, the rule parameters, the allocation source and the points recipient, and should return the number of points.

ParameterDescription
sname of the global JavaScript function that calculates the points

addField(String name, String title)

Returns: PointsRuleTypeBuilder

Adds a configuration field to the rule with just a name and a title.

ParameterDescription
namename of the field, which is also the key its value is stored under
titlelabel shown next to the field

addField(String name, String text, String title)

Returns: PointsRuleTypeBuilder

Adds a configuration field to the rule with helper text alongside its title.

ParameterDescription
namename of the field, which is also the key its value is stored under
texthelper text shown with the field
titlelabel shown next to the field

addField(String name, String text, String title, String options)

Returns: PointsRuleTypeBuilder

Adds a configuration field to the rule from a short field definition string, parsed the same way as other app extra fields.

ParameterDescription
namename of the field, which is also the key its value is stored under
texthelper text shown with the field
titlelabel shown next to the field
optionsfield definition string giving the type and any options, may be null

addField(String name, String text, String title, boolean required, List<String> options)

Returns: PointsRuleTypeBuilder

Adds a configuration field to the rule with a fixed list of select options.

ParameterDescription
namename of the field, which is also the key its value is stored under
texthelper text shown with the field
titlelabel shown next to the field
requiredtrue if the administrator must supply a value
optionsthe values offered in the field's drop down

addFieldWithOptionsFn(String name, String text, String title, boolean required, Supplier optionsFn)

Returns: PointsRuleTypeBuilder

Adds a configuration field whose select options are produced by a supplier function called when the field is rendered, so the options can reflect current account data.

ParameterDescription
namename of the field, which is also the key its value is stored under
texthelper text shown with the field
titlelabel shown next to the field
requiredtrue if the administrator must supply a value
optionsFnsupplier called to produce the list of options
To get full access to the Kademi Hub existing customers can login here, or new customers can register here.