Two common errors when using expressions

Users new to expressions in ACL often make two common errors:

“Expression type mismatch”

In order for an expression to be valid, the data type of the values in the expression must match the calculation or operation you are performing. For example, you cannot multiply two character fields, or divide two date fields. If you try, an “Expression type mismatch” error message is displayed and no processing occurs.

Any of the following methods can allow you to avoid this error, although not all of them may be an appropriate solution for your particular situation:

“Expression type invalid”, or “Logical expression is required”

You must ensure that the return value of an expression is the correct data type for the situation. In many areas of the application where an expression is required, the return value must be a particular data type. If it is not the required data type, an “Expression type invalid” or “Logical expression is required” error message is displayed and no processing occurs. Even if an expression is valid, ACL displays an error message if the expression returns the wrong data type for the situation.

For example, the expression Quantity_on_Hand * Unit_Cost could be generally valid, and work as expected, providing a numeric total, if you use it to create a computed field. However, the same expression would return an error if you used it when creating a view filter or an IF statement, which require that expressions return a logical value of True or False (T or F). If you altered the expression to Quantity_on_Hand * Unit_Cost > 5000 then it would work correctly for a filter or an IF statement.

The key point to be aware of is the location from which you open the Expression Builder. Clicking Edit View Filter  beside the Filter text box, or clicking the If button in various locations, requires the creation of a logical expression in the Expression Builder.



(C) 2015 ACL Services Ltd. All Rights Reserved.