Computed Field

A computed field is a field where the value is a text that can do string interpolation. It appears as a normal read-only field, but with the difference that there is no need to provide an attribute.

Computed field

Figure 1 - Computed field control

Variations

None.

When to use

Use a computed field client control to edit updates of values in real-time, and the ability to calculate an aggregate of records (including their child records).

A computed field can be placed, instead of a regular field in a Group, on Selectors, on Cards, on Lists etc.

How to use

Add the computed field control inside a Group, Selector, Card, or List

list <list_name> {
    ...
    computedfield <computed_field_name> {
        ...
    }
}

Set the properties for the computed field.

Set one or more properties for the computed filed such as label, value, etc. For a complete list of the properties and how to set them, see the Properties section below.

The property value is declared as a string.

computedfield Message {
   value = "Hello World!"
}

The property value is declared with numerical expression that calculates the result for the value field.

computedfield CounterValue {
   label = "Price in ${CurrencyCode}";
   value = "#{Price * CurrencyRate}";
}

Limitations

Aggregate functions are only available when used in a computed field.

A value can take extra time to load, since a computed field loads all child records separately in the background to correctly calculate the sum of them.

A computed field component supports a maximum of 2000 rows. The limit exists to avoid an application to slow down or crash, due to the size of the used entityset.

Properties

Below is a list of properties that can be used to customize the control.

format | label | type | value | visible

Example

The result of the code examples below is shown in Figure 1.

// Computed field using a string. 
computedfield Message {
   value = "Hello World!";
}

// Calculates the sum of the product of Price and Quantity. computedfield Total { value = "#{Orderlines.sum(Price * Quantity)}"; }
// Calculates average per record (row). computedfield AverageLine { label = "Avg per order line"; value = "#{Orderlines.avg(Price * Quantity)}"; }
// Calculates the average per part in the order. computedfield AveragePart { label = "Avg per part"; value = "#{Orderlines.sum(Price * Quantity) / Orderlines.sum(Quantity)}; }

Example 1 - Computed field showing aggregate functions on child records