Skip to main content
Skip table of contents

Creating a Rule

Rules are used to manipulate and retrieve data within an AppBase Solution. Rules can be called by users, events, other rules, scheduled tasks, or from an outside system through a REST call.

You can create a business rule in several ways:

  • Manually create a business rule using the AppBase system.
  • Generate a rule automatically using the AppBase rule generator. AppBase contains many pre-defined business rule templates that may be selected when creating a rule via a rule generator.
  • Generate a rule automatically using the AppBase rule generator and modify it to suit your needs.
  • Create a composite rule using the composite rule builder – this will involve linking several rules together and will be implemented as C# code.



Manually Rule Creation

This procedure explains how to create a business rule for a business object manually. You can modify the rule later if you choose.

  1. Navigate to Business Rules > Rules (1) to open the rules tab.
  2. Click on the New Rule (2) button to open the New Rule tab.
  3. In the Rule Name field, enter a unique rule name
  4. Select a Tag that the rule can be categorized against
  5. In the Rule Usage dropdown list, select the rule function. To check the lists of available rule usages and their meanings, go to Rules Usage.

  6. Enter a description for the rule in the Description field. This is for internal use only but is an important field to complete to ensure that other developers are aware of the purpose of the rule at a high level.
  7. In the API Permanent ID enter a unique name to create an API permanent ID for this attribute. The system will automatically complete this field for you by default, but you can override if required (ensuring no whitespaces or special characters are included)

  8. In the Rule Type dropdown list, select a rule type to assign to the selected rule (i.e., the language that the rule will be written in). The following table lists the possible Rule Types and their meanings.

  9. Specify the Local Path where the rule source code will be saved. Click the magnifier icon and select the Solution Resources (1) select the folder (2) and click the Select path button to save the path. In our example, we have selected the folder Rules/SMPL.
  10. Depending on how the rule will be used, select the Rule must be deployed to option. Options are None, Procedure/Function, Trigger.
  11. Identify if the call of the rule will be case sensitive or not, checking the Is Case Sensitive checkbox.
  12. To specify that the Eval Body is to be used, select Is Eval Body checkbox.
  13. To specify that the rule is to be public, select the Is Public checkbox.
  14. To specify how the response will be treated, select the Encoder. Use Default or None.
  15. Api Call Timeout is an optional property, and it is not necessary to change this value for most of the Solution Rules (for rules that are EXPECTED to run for a long time - like data migration rules, change the property accordingly).

  16. The Data Quota Size constraint is compared to data units consumed by the rule. A negative value disables constraint - the operations will continue normally even if they exceed the configured on the Rule Modify Data Quota Size value. A zero (0) value is an accepted value, but using a zero value will terminate any supported rule after it reads data for rules that do not provide a greater Data Quota Size value on the Rule Modify page.
  17. The Code Body field is the location for the code of the rule (SQL or C#). Paste the code here or type it directly.

  18. When you have finished defining the new rule, click Save at the top of the form. To define more rules, click Save and New.

Using Rule Generator

  1. The rule generator window will appear, which is the starting point for building your rule.
  2. Select the Attributes (Fields). In our example, CaseId and DueDate. Double-click the label to modify the Label if needed.
  3. In the Search Criteria tab, and select the Attribute(s) to search for. In our example, CreatedDate. Check the code, which added a WHERE clause and a parameter.
  4. In the General tab, assign a Name, and a Description of the rule.
  5. In the Parameters tab, verify the name of the parameters. If needed, click the pencil icon to modify the parameter type and default value.
  6. In the Schema Columns tab, verify the output fields. Click the pencil icon to modify the Type if needed.
  7. Click Finish to save the new rule.

Rule Type Description

Rule TypeDescription

CSharp

The rule is written using the C# language within the Microsoft .NET Framework.

SQL

This rule type operates on database tables and fields using exact names specified by SQL code. Tied to the database and database schema. Returns an entire set of records for a specified business entity

SQL Paginated

A rule that returns a paginated set of records

SQL Scalar

A rule that returns a single value

SQL Non Query

A rule that executes SQL that creates, updates, or deletes records within the database

XML

Usually for dictionaries

Spring.NET

Spring.NET is an open-source application framework that promotes well-established patterns in building enterprise .NET applications. One of the features provided by Spring.NET is the ability to set up business rules, create relevant configurations, and execute those rules by means of a framework.

Decision

A decision rule type is used by various solution components when a decision has to be made. For example, those rules may be used for workflows to determine the next Activity and participant in a workflow process. In the workflow, an Activity might be linked to five subsequent Activities. The decision rule determines through which Transition and to which Activity the work item will be sent and to which participant it will be assigned. This sending decision depends on the properties of the work item and/or related business objects.

Extension

Creates a rule type based on a DLL extension that was previously registered. This rule type allows you to select from a list of DLL extensions and then select a specific class and method that should be called. This rule type provides the ability to develop and invoke the functionality of any complexity or use functionality provided by third-party libraries.

Composite

Configures a composite wizard to create a composite rule wherein multiple rules are linked. The final rule is generated in C#


JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.