# Calculation rule action

Use a Calculation rule to dynamically control how the content of a form field, form variable, or global variable is calculated and displayed on a form.

At runtime, the calculation rule is invoked once the user clicks the control where the action is defined.

Example:

A BPM site used by a shipping firm automatically generates and emails invoices to customers. Using a calculation rule, the VAT can be calculated and added to the Subtotal at a rate of 17%.

• If Total = VAT + Subtotal

• Where VAT = 17% of Subtotal

• Then Total = ((17/100)*Subtotal) + Subtotal

• If Subtotal = 200

• Then Total = ((17/100)*200) + 200

• Total = 234

If Total appears in text box 1, and Subtotal in text box 2, following is the calculation rule:

• Text box 1 = ((17/100)*text box 2) + text box 2

• The text box 1 is mapped to output.

When creating a calculation rule, provide a static value or select values from form controls, form variables, or global variables.

If the output type of the calculation is Numeric, and the form contains a Numeric type control, such as a radio button or text box, you can use the value of the selected radio button or text box in the calculation.

Similarly, if the output type of the calculation is String, and the form contains a String type control, such as dropdown, label, radio button, or text box, you can use the values of the selected controls in the calculation.

You can only configure text box and calendar controls as calculated fields, and only use String, Numeric and Date data types.

When a Calendar control is selected as a calculated field, you can only specify Date text boxes and calendars for the first value and numeric for the second values. For example, to send a reminder to a customer for paying the policy premium, you can create a Calculation rule action that sends the reminder to the customer certain days before the due date. Then the calculation rule might be: Calendar1=DueDate - Days (Where DueDate is the last date for paying the premium). In this instance, the DueDate is the Date text box and Days is the numeric text box.

1. On the form modeling bar, click Actions and click New.

The New action dialog box is displayed.

2. On the Type list, select Calculation rule.
3. Change the default Name (CalculationRule1) to something meaningful.
4. Optional. Enter a Description for the action.
5. Optional. Select Multilingual to configure a unique action for each language separately. See Configure multilingual actions.
6. To store the output of the rule, select the required form control, form variable or global variable on the Output list.
7. Right-click on the rule editor and create a Rule using form controls, form variables, or global variables.
Note You can reuse the calculation rule by copying and pasting it in another calculation rule.
8. To validate the rule, click Validate.

The system indicates whether the rule is valid.