📖
Rulecube documentation
v2.4
v2.4
  • Overview
  • Quick Start
  • Tutorial
    • Getting started
    • Create and Run Your First Ruleset
    • Use Constants and Methods
    • Create and Call Functions
    • Adding Testcases
    • Using Lookup Tables
    • Using Entities
    • Using Forms
  • How-to Guides
    • Logging in and Authorization
      • Activate Your Account From an Invitation
      • Log in to Rulecube
      • Change Your Password
      • Recover Your Password
      • Two-factor authentication (2FA)
      • Invite Other Users to Rulecube
      • Edit a User's Role
      • Delete a User
    • Ruleset Development
      • Create a Ruleset
      • Set the Input for a Ruleset
      • Create a Rule
      • Generate Alerts
      • Try out a Ruleset
      • Call a Ruleset from Your Software
      • Entities
        • Create an Entity
        • Drag and Drop a JSON Schema or XSD to create entities
        • Entity instantiation
        • Persisted Entities
      • Constants
        • Constant Tables
      • Functions
      • Built-in Functions
      • Create and Run a Testcase
      • Delete a Ruleset or Components
      • Debugging your Ruleset
    • Create a Workflow
      • Workflow step types
      • Working with documents in a workflow
    • Work with (Environment) Variables
    • Call a Ruleset via Its API From Postman
    • Creating input from JSON Schema
    • Use a Ruleset from Your Software
    • Ruleset Productivity Tips
    • Create an Ockto workflow
    • Alert aggregation
    • Forms
      • Introduction and overview
      • Create a Data table
  • Language Reference
    • Global
    • Array
    • Compression
    • Crypto
    • Date
    • Encryption (deprecated)
    • Finance
    • Http
    • Mail
    • MongoDB
    • Ockto
    • PDF
    • SQL
    • Statistics
    • System
    • UserStore
    • Workflow
Powered by GitBook
On this page
  • Introduction
  • The result of rules as output
  • Procedure
  • Additional resources
  1. How-to Guides
  2. Ruleset Development

Create a Rule

Introduction

This guide explains how to create rules for a ruleset.

Rules are the main engine of rulesets and the logical implementation of a business rule. For example, suppose you implement a business rule for determining the maximum loan amount given a certain income as input. In that case, the rule is the implementation of the business rule that calculates the actual maximum loan amount:

Input
Rule
Output

Income

Calculate maximum loan amount

Maximum loan amount

To distinguish rules at the entity and ruleset level, Rulecube speaks of entity rules and global rules. This guide is about global rules.

The result of rules as output

In general, a rule performs a calculation or makes a decision and returns the result as the output of the ruleset. To facilitate different (business) rule scenarios, Rulecube supports different output types, such as string and date. For instance, the aforementioned maximum loan amount output is of the number type.

List of output types and additional rule/output settings

Output types

  • any As its name implies, an any input can contain any type of input.

  • number This type includes negative values and numbers with decimals.

  • boolean This type expects the values true or false.

  • string This type can contain any text, including numbers.

  • date This type expects a date in mm/dd/yyyy format.

  • enum For this type, you can set a list of possible values. For example, good, bad, ok.

  • array This type contains a one-dimensional array of values.

Additional rule/output settings

  • If you select this type, Rulecube adds the Possible values field to the Rule details page, where you can enter the corresponding values.

  • If you select this type, Rulecube adds the Sub type field to the Rule details page, where you can set the type for the array elements.

Procedure

Let's walk through the steps for creating a rule that calculates the maximum loan amount as 25 percent of a person's annual income.

  1. Create a ruleset named MaxLoan.

  2. Create an input named AnnualIncome with Type = number and Label = The annual income.

  3. Create a constant named LoanPercentage with Type = simple and Value = 25.

  4. Click the + sign behind Rules from the left menu. ↳ The Rule details page opens.

  5. In the Name field, enter the name for the rule. For example, LoanCalculation.

  6. In the Output name field, enter MaximumLoanAmount.

  7. In the Type list, select number.

  8. In the Expression field, enter the following code to calculate the maximum loan amount:

    AnnualIncome * (LoanPercentage / 100)

  9. Click Save.

  10. Try the ruleset out.

Revert changes to an expression

As an extra, let's look at the Revert feature for changes to expressions in Rulecube:

  1. Move back to the rule again.

  2. Change the code for the Expression to:

    AnnualIncome * LoanPercentage / 100

Now, let's assume you are unsatisfied with this change and want the previous code back. You could retype the original code if you remember, but Rulecube enables you to revert the changes much easier:

  1. Press Ctrl+S to save your work.

Additional resources

PreviousSet the Input for a RulesetNextGenerate Alerts

Click above the expression. ↳ Rulecube reverts your changes and shows your original code again.

How-to Guide: .

How-to Guide: .

Try Out a Rule
Call a Rule from Your Software