Create Calculated Fields for a Business Object Based on a DB Table or View

You can create formula and aggregate fields for a business object based on an existing DB table or view to calculate a field's value.

  • To create a field that calculates its value based on a formula:
    1. Select + Field, then Formula Field from your business object's Fields editor.
    2. In the Formula Field dialog box, enter a label for the formula field you want to create, then select the field's Type.
    3. Enter a valid expression for the formula in the text area. You can specify operands by typing in the text area or by selecting the Insert arrow for a field in the list of available fields. Click an operator in the toolbar to add it to the formula.

      You can create a formula to calculate a numerical value such as a percentage, or you can create a Groovy expression that uses available fields to generate a value. For example, you can concatenate strings stored in local fields (firstName + ‘ ‘ + lastName) or determine a value based on a comparison or logical expression (qualityLevel != 5).

    4. Click Create Field.
    5. Optional: When you define a Groovy expression, you can click the Timeout Override icon icon in the Properties pane to override the default Groovy timeout.
  • To create a field that aggregates the data of related business objects:
    1. Select + Field, then Aggregation Field from your business object's Fields editor.

      The Aggregation Field option won't show if your business object doesn't have incoming relationships. For example, if you created a field in the Employee business object that refers to the Department object, Employee is considered the source object and Department the target object. Department, in this case, is said to have an incoming relationship with Employee.

    2. In the Aggregation Field dialog box, enter a label for the aggregation field you want to create.
    3. Select the object to aggregate (for example, the Employee business object which uses Department as a target business object), the aggregation function (which can be Average, Count, Maximum, Minimum, or Total), and the field to aggregate (for example, Salary).
    4. Click Create Field.