Introduction

Getting started

Walkthrough Guides

CafeX Apps

App Studio

App Studio Components

Data Sets

Workflows

Using CafeX Collaborate App

Reporting

Managing CafeX

Integrating CafeX

Security

How-tos

How-tos

Using Rulesets in Data Tables

Modified on Wed, 1 Oct at 8:13 AM

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:

  1. Create a ruleset named DiscountPolicy.
  2. 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.
  3. Define input facts:
    Input fact: CustomerType, type: Text;
    Input fact: OrderAmount, type: Number.
    Input Facts are required for rules to evaluate correctly.
  4. Define result facts:
    Result fact: DiscountRate, type: Number, default value: 0.
    Result Facts are automatically populated in the table.
  5. Configure rules:
    1. PremiumHighValue
      • Conditions: {CustomerType} = "Premium" and {OrderAmount} > 1000.

      • Action: {DiscountRate} = 15.
        This rule rewards premium customers with large orders.

    2. PremiumDefault
      • Conditions: {CustomerType} = "Premium" and {OrderAmount} ≤ 1000.

      • Action: {DiscountRate} = 10.
        This rule ensures premium customers always receive a base discount.

    3. StandardDefault
      • Conditions: {CustomerType} = "Standard".

      • Action: {DiscountRate} = 5.
        This rule ensures standard customers still get a smaller discount.

  6. 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:

  1. Add a new data table.
  2. Create the fields:
    Customer Type with type Text,
    Order Amount with type Number.
    These fields correspond to the Input facts required by the ruleset.
  3. Add a new Discount Rate (Result) field of type Ruleset, and select the ruleset you created earlier (for example, DiscountPolicy).
  4. Ensure that each input fact maps to a corresponding table field, and the result fact maps to the Ruleset fact (DiscountRate).
  5. 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

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article