View Article

Configure a Calculated Field

By Xelence Documentation posted 02-16-2022 10:56

  

Introduction

A calculated field is a custom value that uses existing entity attributes to calculate a result via logical rule. This allows you to create a new field from the attributes that are already part of the entity, without changing those attributes in any way. You can then display this value on a maintenance form; it will update whenever the fields it uses in calculation update.

This example defines a calculated field that returns the total amount spent on a given product by multiplying the number of products by the price and subtracting any discount. After creating and compiling the calculated field, you can test the rule in an entity scenario to confirm it calculates the values you expect.

Prerequisites

The entity must exist.

Quick Steps
1 Search for and open the entity
2 Open the Attributes section, then open the Calculated Fields section
3 Add a calculated field
4 Enter the details, then click OK
5 Design the rule
6 Configure the rule components
7 Save the entity, then compile the rule
8 Open the scenario
9 Enter the values, then run the test
10 View the result diagram
11 Save the scenario

Detailed Steps

Step 1. Search for and open the entity.

The form's entity is where you configure its calculated fields.


Step 2. Open the Attributes section, then open the Calculated Fields section.

This is where you create calculated fields that can be used on maintenance forms later.


Step 3. Add a calculated field.

Click the Create New icon to add a new calculated field.



Step 4. Enter the details, then click OK.

The properties are:

  • Name (ID): This is the calculated field's programmatic ID. This property is required. The ID must be unique, and it cannot start with numbers.
  • Access Modifier: Determines the accessibility of the field.
  • Trace: Making a rule traceable helps you to view the rule details every time the rules get executed on the LOB.
  • Data Type: Data type of the value the calculated field will return, such as int, decimal, etc.
  • Caption: Text Xelence will use for the calculated field's caption when the field is used on a form.
  • Skip From Platform Api: If checked, the field can be accessed from platform API, otherwise it cannot be accessed.
  • Description: Optionally, you can add a description for the calculated field.
The Access Modifier options are:

Public: Any entity can access this calculated field.
Private: Only this entity can access this calculated field.
Protected: Only this entity and any child entity can access this calculated field.



Step 5. Design the rule.

Xelence creates a new rule for the calculated field as an empty field. You must build the flowchart for the rule by dragging and dropping components from the toolbox.

For this rule example, add a return component.



Step 6. Configure 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.

There are two options for viewing your rule. In Developer View, descriptions and expressions both display. You can also view a rule in Analyst View, where only descriptions display. It is possible for one person to create a rule in Analyst View with only description, and for another person to finish the rule later with the actual logic.



Step 7. Save the entity, then compile the rule.

The rule is completely defined. Click the Save icon to save the entity.


You must compile the rule so it can be called. Click the Compile Rule icon.



Step 8. Open the scenario.

To test the rule, click the Navigate to Scenario icon and select Navigate to Entity Based Scenario.



Step 9. Enter the values, then run the test.

Enter the input field values for the test. Optionally, you can enter the value you expect the rule to return.

Click the Run Test icon and select the Current Rule from the available options to run the test step. View the result executed based on the input field values.



Step 10. View the result diagram.

If you want to trace the executed logic, click the View Test Result icon to open the result diagram.

The result diagram shows the calculated return value. Click the Close icon to close the diagram.



Step 11. Save the scenario.

Click the Save icon to save the scenario.



What are the improvements over S3 Version 6?

This is a new process.


Related Articles

Create Entities with an Excel File

Create Entities with a Table

Create an Entity First


This post is part of the Entity topic. Click here to open the Entity Overview.


#Xelence
#Entity

0 comments
117 views