Rule Result
Last updated
Last updated
Rule results in Nected define the output of a rule based on its evaluation. They are fundamental for translating the rules' logic into actionable data that can be used within the application. Rule results determine the type of data returned—such as Boolean, Numeric, String, DateTime, JSON, List, JS Code, or Formula—allowing for a wide range of responses tailored to specific business needs or application requirements.
The purpose of rule results is to provide a clear, dynamic, and context-specific output that can be integrated into the broader application ecosystem. Whether it's triggering specific actions, influencing user interfaces, or driving decision-making processes, rule results enable customizable and scalable responses based on user-defined conditions.
Rule Result is available only for SimpleRule & DecisionTable. It is not available in the Ruleset. You can define output based on matching conditions as per each rule.
When you add data, you specify the type of result you expect from the rule. Nected offers various result data types, including Boolean, Numeric, String, DateTime, JSON, List, JS Code, and Formula. The choice of data type depends on the nature of the rule and the desired outcome.
Nected supports the following nine types of output data and results:
Boolean: Use the Boolean type for rule results that require a binary outcome, such as "true" or "false." This type is suitable for decision-making scenarios where the rule needs to confirm or deny a condition based on its evaluation. Like, a rule that checks if a user's input meets certain criteria (e.g., password strength) can return true if the criteria are met and false otherwise.
Numeric: The Numeric type handles numbers, including integers and decimals. It is useful for rules that need to calculate values or assess numerical conditions. As a rule, calculating a discount based on purchase volume would use a numeric result to specify the percentage of the discount.
String: The String type allows for returning textual data. This versatile type can be used in various contexts, such as generating status messages or labels based on rule evaluation. A rule determining a user’s membership level could return strings like "Gold," "Silver," or "Bronze."
Date: Use the Date type for rules that operate based on specific dates. This type is crucial for scenarios where the outcome depends on time-sensitive conditions. A rule that checks whether a promotional offer has expired might return the expiration date of the offer.
DateTime: Use the DateTime type for rules that operate based on specific dates and times. The DateTime format follows the RFC3339 standard, like 2024-08-07T12:46:00+05:30. This type is crucial for scenarios where the outcome depends on time-sensitive conditions.
JSON: The JSON type is used to return structured data. This format is ideal for complex information that involves multiple levels of detail, which UI elements or other applications can consume. A rule could return a JSON object containing customized user profile information, which a client application can then render accordingly.
List: The List type handles collections of items, such as arrays or lists of values. It’s useful in scenarios where the rule needs to return multiple values or evaluate conditions across a set of items.
JS Code: The JS Code type allows users to craft complex results using attribute tokens within a JavaScript editor. This type is suitable for creating dynamic rule responses through custom JavaScript code.
Formula: The Formula type is designed for quickly writing Excel-like formulas using tokens to perform mathematical operations. It leverages macros like SUM, SUM_List, MAX, MAX_List, etc., allowing for efficient data manipulation.
Any result would be available as token in the result defined after that result, with the name .outputdata
Note: The result would be available as a token only in the results defined after this result. The current result key token would not be available in any of the conditions as well as any of the results defined before this result key.