Rule Builder (Formerly Formula Constraints)
Introduction
The Rule Builder is a powerful tool for managing complex configuration logic within your configurator. It is composed of three main components:
| Component | Description |
|---|---|
| Formula Constraints | Define conditions and effects for specific rules or logic within the configurator. Can reference Saved Expressions. |
| Formula Constraint Categories | Organizational tags or labels to group and categorize formula constraints for better management. |
| Saved Expressions | Reusable formulas or expressions that can be referenced across multiple formula constraints. |
Formula Constraints
Formula constraints are the backbone of the logic in your configurator. They define when specific actions should occur and what should happen when those conditions are met.
Fields within Formula Constraints
| Field | Description | Details |
|---|---|---|
| Name | The name of the formula constraint. | Used to identify the constraint easily. |
| Description | A markdown field to provide additional context or details about the constraint. | Supports rich formatting for clarity and emphasis. |
| Ordering | Defines the execution order for the formula constraint. | Lower numbers run first. |
| Formula Constraint Categories | Allows you to assign the constraint to one or more categories. | Helps with organizing and grouping related constraints. |
Building a Formula Constraint
Once the basic fields are inputted, you can begin defining the logic of the formula constraint. This logic consists of two main parts:
| Component | Description | Details |
|---|---|---|
| Conditions | Define the specific conditions that must be met to execute the constraint. | Essentially defines when the constraint should run. |
| Effects | Specify the actions or outcomes that occur when the conditions are satisfied. | Essentially defines what happens when the constraint runs. |
Next Steps
You can now elaborate further on Conditions and Effects, detailing their configurations, structure, and examples. This table-driven overview provides a foundation for more in-depth documentation.
Conditions
When building a condition in the Formula Constraint Builder, you define the logic that determines when specific effects should be executed. A condition can be constructed using one of three main approaches:
Options for Building a Condition
| Option | Description | Details |
|---|---|---|
| Build an Expression | Create a custom equation using operators and functions. | See the list of available operators and functions below. |
| Condition on Values | Define conditions based on specific values or criteria (e.g., numbers, strings, user input). | See the list of possible value-based conditions below. |
| Use a Saved Expression | Reference a previously created and saved expression for reuse. | Enables consistency and efficiency by avoiding redundant logic. |
Option 1: Build an Expression
When building an expression, you can utilize a variety of operators and functions to create complex conditions. Below is the complete list:
| Operator/Function | Symbol | Description |
|---|---|---|
| And | && | Logical AND; returns true if both conditions are true. |
| Or | ` | Logical OR; returns true if at least one condition is true. |
| Not | ! | Logical NOT; negates the condition. |
| Xor | ^ | Logical XOR; true if only one of the conditions is true. |
| Add | + | Adds two values. |
| Sub | - | Subtracts one value from another. |
| Mul | * | Multiplies two values. |
| Div | / | Divides one value by another. |
| Mod | % | Returns the remainder of a division. |
| Pow | ^ | Raises a number to a power. |
| Tan | - | Calculates the tangent of a value. |
| Sin | - | Calculates the sine of a value. |
| Cos | - | Calculates the cosine of a value. |
| Atan | - | Calculates the arctangent of a value. |
| Asin | - | Calculates the arcsine of a value. |
| Acos | - | Calculates the arccosine of a value. |
| Avg | - | Calculates the average of a set of values. |
| Median | - | Calculates the median of a set of values. |
| Abs | - | Returns the absolute value of a number. |
| Round | - | Rounds a number to the nearest integer. |
| Ceil | - | Rounds a number up to the nearest integer. |
| Floor | - | Rounds a number down to the nearest integer. |
| Min | - | Returns the smallest value in a set. |
| Max | - | Returns the largest value in a set. |
| Lt | < | Less than. |
| Lte | <= | Less than or equal to. |
| Eq | == | Equal to. |
| Neq | != | Not equal to. |
| Gt | > | Greater than. |
| Gte | >= | Greater than or equal to. |
Option 2: Condition on Values
You can create conditions based on the following value types:
| Value Type | Description |
|---|---|
| Number | A numeric value to evaluate. |
| Boolean | A true or false value. |
| String | A string (text) value to evaluate. |
| User Level | The user’s role or level within the system. |
| Option Selected | Whether a specific option is selected. |
| Quantity | The quantity of a selected option. |
| Price | The price of a selected option or configuration. |
| Value | A specific value within the configuration. |
| Length | The length of a string or numerical value. |
| Num Selected | The number of selected options. |
| Num Options | The total number of options available. |
| At Least One Selected | Checks if at least one option is selected. |
| All Selected | Checks if all options in a group are selected. |
| Country | The user’s country. |
| Is User | Validates whether the condition pertains to a specific user. |
Option 3: Use a Saved Expression
If a previously created Saved Expression fits your condition, you can directly reference it. This approach is highly flexible and efficient, as saved expressions can be used in two ways:
- Inside Formula Constraints: Incorporate saved expressions directly within the logic of your formula constraints to simplify complex equations.
- As Values: Use saved expressions as input values when building conditions to ensure consistency across the configurator.
Next Steps
You can now dive deeper into configuring Effects, or expand further on the specifics of building conditions. Let me know how you’d like to proceed!
Effects
The Effects section of the Formula Constraint Builder allows you to define the outcomes that occur when conditions are satisfied. Effects control the behavior of options, elements, and groups, providing powerful customization capabilities.
Key Features of Effects
- Change Order:
- Specify the order in which effects are executed within a constraint.
- Assign a priority (e.g., first, second, third) to determine the sequence of execution.
- Name and Description:
- Assign a name to the effect for easy identification.
- Provide a description using a markdown field for context or additional details.
Effect Configuration
Each effect within a constraint can be configured by selecting the appropriate Effect Type and its corresponding Target. Below is a comprehensive list of effect types and their functionalities:
| Effect Type | Description | Applies To |
|---|---|---|
| Show | Makes an option, element, or group visible. | Options, Elements, Groups |
| Hide | Hides an option, element, or group, making it invisible in the configurator. | Options, Elements, Groups |
| Require | Marks an element or group as mandatory. | Elements, Groups |
| Optional | Marks an element or group as optional. | Elements, Groups |
| Readonly | Disables interaction with an option, element, or group while keeping it visible. | Options, Elements, Groups |
| Unset | Removes the value of an option or element. | Options, Elements |
| Set | Assigns a specific value (e.g., true for a boolean) to an option or element. | Options, Elements |
| Set Quantity | Sets the quantity of an option or element based on a formula. | Options, Elements |
| Message | Displays a custom message to the user. Useful for providing guidance or context in the configurator | Options, Elements, Groups |
| Error | Displays an error message when conditions are not met. Ideal for enforcing critical rules. | Options, Elements, Groups |
| Warning | Displays a warning message when conditions might lead to issues but do not prevent further action. Helps alert users without blocking progress. | Options, Elements, Groups |
| Success | Useful for confirming that a configuration step was completed correctly. | Options, Elements, Groups |
How to Configure an Effect
- Select Effect Type:
- Use the table above to choose the effect type that fits your configuration logic.
- Select Target:
- Choose the specific option, element, or group that the effect will act upon.
- Set Parameters:
- Depending on the effect type, you may need to input additional parameters (e.g., a formula for Set Quantity or a boolean for Set).