CalculateFields

Evaluates a specified expression as either True or False.

Syntax

bool CalculateFields (string Equation, string DecimalDigits, string PreserveStatus)

Parameters

Smart parameters are supported.

Equation

The expression to evaluate. An expression consists of two or more subexpressions as defined by comparison operators (such as “=” or “>”). For example, if an expression has one comparison operator, it has two subexpressions: one subexpression to the left of the comparison operator and one subexpression to the right of the comparison operator. If an expression has two comparison operators, it has three subexpressions. And so on.

Each subexpression consists of one or more terms that are separated by arithmetic operators (+,-,*,/,^). A term can be a numeric constant or the name of a field object. The fields that a subexpression references are called dependent fields. Surround any dependent field names with single quotation marks (‘).

Any dependent field with a value of null is treated as if the field had a value of zero.

Restriction: A locale mismatch can prevent this action from properly evaluating the expression. A mismatch occurs if the value of a dependent field is not formatted for that field’s locale. For information about setting the locale, see Setting locale values.
DecimalDigits
Optional. The number of decimal places to use for comparing the numerical results of subexpressions.
PreserveStatus
Optional. There are two possible values that determine whether the validation status of dependent fields is updated:
"True"

The validation status of dependent fields is not updated.

"False"
The validation status of dependent fields is updated in the following manner:
  • If the expression evaluates to False, the validation status of dependent fields is updated to a failed status value. For information about validation failures, see Show validation failures to an operator.
  • If the expression evaluates to True, the validation status of dependent fields is updated to a done status value.
Important: The validation status of dependent fields could be updated by other rules and actions. When you configure your application, sequence your validation logic to work in tandem with this action.

The default value is “False”.

Returns

True if the expression can be evaluated and the expression evaluates to True. Otherwise, the action returns False.

For example, the expression cannot be evaluated if a field’s value is not numeric.

Level

Field level.

Details

Example
Code Comment
CalculateFields("'SubTotal' + 'Shipping' + 'Tax' = 'Total'")
 
CalculateFields("('SubTotal' + 'Shipping' + 'Tax') - '0.05' = 'Total'")
 

CalculateFields("('Wages' + 'Interest' + 'Unemployment')>=('Gross'-'.05')")
CalculateFields("('Wages' + 'Interest' + 'Unemployment')<=('Gross'+'.05')")
Call this action twice to validate that the result is within a range.