MX-Frame Library Send comments on this topic.
Value Expression
See Also
MX-Developer > Data Access Layer - MxAdapter > Designing Data Source > Schema > Designing a Field > Value Expression

Glossary Item Box

Value expression defines a calculated value of a field. It is appropriate to use such functionality when some data cannot be obtained from only one data source or the value is a mixture of several different types of data such as variables from data source, system variables, environment variables, etc.

The value is defined with Expression Designer. This means that the developer has wide variety of options and possibilities when calculating such a value. It can depend on all kinds of variables. Variables can be manipulated with any of the functions available in Expression Designer.

Value expression is a must be feature in application with sophisticated business logic. Using it, it is possible to even more customize an application.

Example (MxSpace)

To see the implementation of value expression in MxSpace application click Production -> Manage. In the user interface for managing work orders in the grid displaying work order head, value of the field +-[%] is calculated from values of fields Planned Qty. and Actual Qty.

To implement value expression

  1. Open appropriate adapter (WorkOrderAdapter) in Solution Explorer.
  2. Right click appropriate data source schema (WorkOrder) and select Add Field.
  3. Expand the newly created field and select Value Expression node.
  4. With Expression Designer build appropriate value. *

* In MxSpace the following expression is used: If((IsNull([DataSources.WorkOrder.PlannedQuantity]) || IsNull([DataSources.WorkOrder.ActualQuantity]) || ([DataSources.WorkOrder.PlannedQuantity] = 0)),0,(100 * [DataSources.WorkOrder.ActualQuantity] / [DataSources.WorkOrder.PlannedQuantity]) - 100)

In If clause both fields are checked for actual values. When performing math operations field cannot be Null. Furthermore value in field PlannedQuantity is also checked if it is zero. It is not possible to divide a number by zero. In case one of the values is Null or PlannedQuantity value is zero the value returned is zero. Otherwise the formula for deviation is calculated.

See Also

©2009 Metronik. All Rights Reserved.