Formulas

Some kinds of fields can have their value determined by a simple formula. The simple formula mechanism works about the same way for each data type it can be used with.

There also is an extended formula mechanism. Extended formulas are more powerful and complicated than simple formulas. Extended formulas are described in Application Building for the IBM TRIRIGA Application Platform: Calculations. The following paragraphs describe simple formulas.

A simple formula determines the value of a field from the values of other fields in the same record. For example, we may want to have a formula determine when a training session will end based on the time that it starts and its duration.

Some formulas may involve the use of a constant. For example, you may want the amount of money you budget for a certain kind of project to be 10% greater than the estimated amount. To do this, we need to multiply by 1.1. Simple formulas work with fields, not constants, so we cannot put 1.1 directly in a simple formula.

What you can do is add to the business object a read-only field that has a default value of 1.1. You would not normally include such a field in a user interface. Generally, creating fields that are constants is not a good idea since the system will have to store the value for each record that is created.

Now that you know what simple formulas can do, we are ready to look at the mechanics of specifying a simple formula. Though some details vary from one data type to another, the idea is that you select a field and then an operator and then a field until you have entered the entire formula. To make this clearer, we will work through the example of defining a field to contain a budget amount that is 10% more than an estimated amount.

Let us suppose a business object named RepairProject already has a field named EstimatedCost to contain the estimated cost of a repair. Also suppose that the business object has a read-only field named ErrorMargin whose value is 1.1. We want to define a field named BudgetCost that will contain the budget amount. Check the Formula check box and selected the Regular Formula Type.

To enter the formula, click the first Find hyperlink. Clicking the Find hyperlink causes a form to appear under the field's properties that allows us to select a field.

To select a field, first select the section that contains the field. If the field is not in a section, select the name General. Next, select the field. Following this procedure, we select the General section and then the Error Margin field. Finish by clicking the Accept action.

Operators are selected from the drop-down list to the right of the field we just found. Select * (indicating multiplication) from the drop-down list.

Repeat the process of selecting a field to select the EstimatedCost field.

When the value of a field is computed by a formula, you may want the field's unit of measure to be determined by the one of the fields that the formula uses. In this case, we want this field to have the same unit of measure as the EstimatedCost field; set the value of the UOM Source Attribute property to Estimated Cost.