Introduction
Logical rules are structured in a way that they define relationships, operations, or conditions that must be met for a particular conclusion or outcome to be valid. These rules are often used in reasoning, decision-making systems, and programming.
This example is a very simple logical rule just to demonstrate the interface. It determines the status of a record based on its verification.
After creating the rule, you can test it to confirm it works as expected.
Prerequisites
The entity must exist.
|
Quick Steps |
| 1 |
Click the Create New Item icon, then select the Object Type |
| 2 |
Select the Rule Type |
| 3 |
Enter the rule details, then click OK |
| 4 |
Write your rule logic in X# |
| 5 |
Enter the logic for the rule components |
| 6 |
Declare any variables |
| 7 |
Save and compile the rule |
| 8 |
Open the scenario, then open the test case |
| 9 |
Enter the values and run the test |
| 10 |
View the result diagram |
| 11 |
Save the scenario |
Detailed Steps
Step 1. Click the Create New Item icon, then select the Object Type.
The Create New Item icon is in the top left corner of Xelence’s landing page.
It begins the process of creating a new logical rule.
Step 2. Select the Rule Type.
The Object Type identifies the file the wizard will create. This example creates a logical rule.
Step 3. Enter the rule details, then click Ok.
The properties are:
- Entity: The rule is based on the entity. The fields available to the rule will be based on this entity's attributes.
- Name (ID): This is the rule's programmatic ID. This property is required. The ID must be unique, and it cannot start with numbers.
- Access Modifier: Specifies the level of accessibility of the rule.
- Return Type: This is the data type of the result you expect the rule to return (string, int, etc.).
- Is Collection: This is available when the logical rule returns a result. If checked, the rule can return a collection.
- Static: If checked, the rule will be available to call from anywhere. Otherwise, you will have to call it from an instance of its object. In a logical rule, the attributes of the entity can be directly used if it is not static.
- Allow From Platform Api: If checked, the rule will be available from Platform API.
- Trace: Making a rule traceable means you can view the path and result every time the code executes that rule.
- Description: Optionally, you can enter a short description for your rule.
The Access Specifier options are:
Public: The rule is accessible from anywhere.
Private: The rule is accessible only from the current entity rules.
Protected: The rule is accessible only from this entity and any child entity.
Step 4. Write your rule logic in X#.
Xelence creates a new logical rule as a default empty page. You can build the rule by adding the code in X#. Alternatively, you can also build the rule flowchart by dragging and dropping components from the Toolbox in the Design mode. Refer Logical Rule Elements to get more details about Toolbox elements.
Step 5. Enter the logic for the rule components.
For each component, enter the description of what it does in the rule, then enter the expression. An expression is the actual logic that your application executes when it calls the rule.
Press Control key (ctrl) and / together on the keyboard to comment or uncomment any desired code block.
Based on the results, the rule will take a defined action.
The rule returns a value based on the action it took.
In this rule, Productverificationind is not defined as a variable. Instead, it's an attribute of the Product entity.
Step 6. Declare any variables.
You must add any undefined components as variables by specifying the below properties:
- Data Type: Type of data the variable uses (string, int, bool, etc.).
- Variable Name: String you are adding as a variable.
- Default: If the variable is local, you can assign it a default value.
You can also declare the variables before you enter the logic for the rule components.
This is how the logical rule flowchart appears when opened in Design mode.
#Xelence
#Rules