Rule Set
Multiple conditions may need to be evaluated before deciding the final outcome—for example, identifying whether a ledger belongs to a particular group, checking if bill-wise details are enabled, classifying vouchers based on amount range, or validating transactions quarter-wise. Writing all these checks separately can make the logic repetitive and difficult to maintain. Rule Set is a definition type that allows developers to define a set of related rules which are evaluated together in the current context. Each rule contains a condition and its corresponding result, and the evaluated output can further be used for validations, classifications, filtering, or conditional processing. By grouping rules in a structured manner, Rule Set helps simplify complex decision-making logic and makes TDL code cleaner, reusable, and easier to manage.
Syntax
[Rule Set : <Rule Set Name>]
➥ Download the Rule Set Samples
Attributes
Aggr Rule is an attribute used in a Rule Set to define precomputed aggregation results based on multiple rule evaluations. Instead of checking individual rule results repeatedly, Aggr Rule allows developers to combine them using aggregation types such as Any True (OR) or All True (AND) and store the combined outcome with an identifier for easy access later through the FlagSet. The attribute can also optionally specify the Rule Set level from which the aggregation should be considered. This is especially useful in scenarios where the final decision depends on evaluating multiple related conditions together for example, validating whether all required checks are satisfied before accepting a transaction, or verifying if any one rule among multiple conditions has succeeded. By using Aggr Rule, complex rule evaluations become easier to organise, access, and reuse within TDL.
Syntax
Aggr Rule : <Identifier> : <AggrRuleParam> [:<RuleSetLevel>]
Where,
Identifier can be accessed later from the flagset.
AggrRuleParam is type of aggregation to be done (Any True / OR, All True / AND).
RuleSetLevel is an optional parameter indicating the level to be considered for aggregation. This is always relative to ‘Current Ruleset’. Default level if not specified is One.
Example
[Rule Set : TSPL SMP Voucher Count]
Aggr Rule : TotalVouchers : Count
This can be used to compute the total number of vouchers processed within the Rule Set, avoiding repeated counting logic.
A Rule Set can contain multiple rules, but evaluating every rule may not always be necessary once a required outcome is determined. Break On is an attribute used to control whether rule evaluation should continue or stop after evaluating the current rule, thereby providing vertical flow control during Rule Set execution. For example, while validating a transaction or classifying a ledger, a single matching condition may itself be enough to decide the result, making further evaluation unnecessary. If Break On : Yes is specified, evaluation stops as soon as a rule returns True, and the remaining rules are automatically treated as No. If Break On : No is specified, evaluation stops when a rule returns False. If the attribute is not specified, all rules continue to be evaluated irrespective of their result. By using Break On, developers can optimise rule processing and simplify decision-making logic within TDL.
Syntax
Break On : <Yes/No>
Example
[Rule Set : TSPL SMP Voucher Count]
Break On : Yes
Here, once a rule condition is satisfied, further rule evaluation in this Rule Set stops immediately because Break On is set to Yes.
Rule conditions can sometimes become lengthy and difficult to read, especially when the same logical expression needs to be used across multiple rules within a Rule Set. Local Formula is used to define temporary formulas inside the Rule Set so that complex conditions can be written once and reused wherever required. These formulas remain scoped only to the current Rule Set and cannot be accessed outside it. By using Local Formula, developers can simplify rule definitions, improve readability, and make complex validations easier to manage and maintain.
Syntax
Local Formula : <Formula Name> : <Expression>
Example
[Rule Set : TSPL SMP Voucher Count]
Local Formula : JanToMar : $$Number:$$MonthOfDate:$Date <= 3
This defines a formula JanToMar which checks whether the voucher date falls within the first three months. This formula is later used in rule evaluation.
Name Map is an attribute used to associate a Rule identifier with a specific descriptive string from a Name Set. It acts as a bridge between Rule evaluation and the corresponding message or description that should be displayed for that rule. The first parameter specifies the Rule identifier, the second specifies the Name identifier from the Name Set, and the optional third parameter allows a different Name Set definition to be referenced. Instead of directly embedding validation or error messages within Rule logic, Name Map enables developers to centrally map and manage rule descriptions, making Rule Sets cleaner, easier to maintain, and more suitable for localisation. Name Map is typically used when rule-specific messages need to be associated dynamically during Rule evaluation, whereas Name Set alone is used only for defining and storing reusable strings.
Syntax
Name Map : <Rule Identifier> : <Name Identifier> : <Name Set>
Example
[Rule Set : TSPL SMP Amount Count]
Name Map : LessThanTenK : LessThanTenK : TSPLAmountDescriptions
Name Map : LessThanTwentyK : LessThanTwentyK : TSPLAmountDescriptions
Name Map : Tw0Kto30K : Tw0Kto30K : TSPLAmountDescriptions
Name Map : Th0K : Th0K : TSPLAmountDescriptions
Name Set attribute specifies the Name Set definition to be used for mapping rule identifiers to their corresponding descriptions. All rule messages are derived from this Name Set.
Syntax
Name Set : <Name Set Definition>
Example
[Name Set : TSPLAmountDescriptions]
List Name : LessThanTenK : “Amount below 10,000”
List Name : LessThanTwentyK : “Amount between 10,000 and 20,000”
List Name : Tw0Kto30K : “Amount between 20,000 and 30,000”
List Name : Th0K : “Amount above 30,000”
[Rule Set : TSPL SMP Amount Count]
Name Set : TSPLAmountDescriptions
Rule : LessThanTenK : @LessThanTenK
Rule : LessThanTwentyK : @LessThanTwentyK
Rule : Tw0Kto30K : @Tw0Kto30K
Rule : Th0K : @Th0K
Rule defines an individual rule within the Rule Set. Each rule consists of an identifier, a condition to evaluate, and an optional flow control directive.
Syntax
Rule : <Rule Identifier> : <Condition> : <Break Value>
Example
[Rule Set : TSPL SMP Voucher Count]
Rule : JanToMar : @JanToMar
This rule evaluates the condition defined in the local formula JanToMar. If the condition is satisfied, the rule is considered true.
Rule Set attribute is used to define a hierarchical structure by linking another Rule Set as the next level (dimension). It allows multi-level rule evaluation.
Syntax
Rule Set : <Next Rule Set> : <Current Rules> : <Next Rules>
Example
[Rule Set : TSPL SMP Voucher Count]
Rule Set : TSPL SMP Amount Count
This links the Rule Set TSPL SMP Amount Count as the next dimension. After evaluating the current Rule Set, this linked Rule Set is also evaluated.
Walk On controls whether the next dimensional Rule Set should be evaluated after executing the current rule. It manages hierarchical rule execution flow.
Syntax
Walk On : <Yes/No>
Example
[Rule Set : TSPL SMP Voucher Count]
Walk On : Yes
Since Walk On is set to Yes, after evaluating the current rule, the next Rule Set (TSPL SMP Amount Count) will also be executed.
