TABLE OF CONTENTS
Rulesets and Ruleset Data Fields
Rulesets allow you to apply predefined business logic directly within a data table. You can configure rules once in a ruleset and then reuse them across different tables instead of writing complex formulas repeatedly.
A Ruleset field in a data table applies a ruleset to evaluate input facts and produce result facts.
- Input facts are the data your ruleset uses to evaluate conditions.
- Result facts are the outputs generated by the ruleset, which become available as fields in your table.
When a ruleset is added to a data table, the App automatically evaluates the rules against the input data for each row and populates the results.
For more information, see the detailed articles on Rulesets and Data Tables.
Example: Applying a Ruleset in a Data Table
In the example below, we'll configure a ruleset that calculates discount rates for customers based on their type and order amount and then connect it to a data table to populate results automatically.
Configuring the Ruleset
In our example, the DiscountPolicy ruleset calculates the appropriate discount rate depending on the customer type and order amount.
To configure the DiscountPolicy ruleset:
- Create a ruleset named DiscountPolicy.
- Review options for rule processing. By default, all rules in a ruleset are processed in order. If you want evaluation to stop once a rule matches (or doesn’t match), you can adjust this behavior in the Options section.
- Define input facts:
Input fact: CustomerType, type: Text;
Input fact: OrderAmount, type: Number.
Input Facts are required for rules to evaluate correctly. - Define result facts:
Result fact: DiscountRate, type: Number, default value: 0.
Result Facts are automatically populated in the table. - Configure rules:
- PremiumHighValue
Conditions: {CustomerType} = "Premium" and {OrderAmount} > 1000.
Action: {DiscountRate} = 15.
This rule rewards premium customers with large orders.
- PremiumDefault
Conditions: {CustomerType} = "Premium" and {OrderAmount} ≤ 1000.
Action: {DiscountRate} = 10.
This rule ensures premium customers always receive a base discount.
- StandardDefault
Conditions: {CustomerType} = "Standard".
Action: {DiscountRate} = 5.
This rule ensures standard customers still get a smaller discount.
- PremiumHighValue
Save your changes.
Configuring the Data Table
To use a ruleset in a data table, you need to connect the ruleset’s input and result facts to your table’s fields.
To configure the data table:
- Add a new data table.
- Create the fields:
Customer Type with type Text,
Order Amount with type Number.
These fields correspond to the Input facts required by the ruleset. - Add a new Discount Rate (Result) field of type Ruleset, and select the ruleset you created earlier (for example, DiscountPolicy).
- Ensure that each input fact maps to a corresponding table field, and the result fact maps to the Ruleset fact (DiscountRate).
- Save your changes.
Testing the Ruleset
To test the ruleset, set up a Data Table View to display the table; see Creating a Data Table View for details.
When you enter sample data into the table, the ruleset automatically calculates discounts:
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article