Expression Types

About Expression Types

This section provides information about types of Expressions. The different types of expressions are:

Regular Expression

A regular expression is a script that computes the values for a target property as defined in the Expression data model. An Expression is executed when a record is inserted or updated in a class to which the expression is attached (when the Expression is set to Is Active mode). You can calculate the average, sum, division, concatenation, and so on of the values for the properties of a particular class.

The block diagram depicts a typical representation of an expression and its relationship to the classes and properties in the Expression Management data model.

This table describes the variables defined in the expression:

Variable Description

retValue

Target Property

B

Source Property 1

C

Source Property 2

The values in the variables B and C are added and the result is assigned to the variable retValue which in turn is assigned to the target property.


For example, A4 = A1+ A2 is a regular expression, where, A1, A2, and A4 are variables you define

Order of Execution

This section explains the order of the execution of the variables.

The order of execution of variables is:

  1. The Expression Engine will be called after the beforeDB CF. For example, The order of execution for CF and Expression Engine while updating an Item is:

  • beforeModify

  • beforeDBModify

  • Expression Engine

  • afterDBModify

  1. Expressions are inherited. In case there is an expression on a bottom class and its parent class both of which targets the same property, then the expression on the bottom class overrides that on the parent class.

  2. There is no defined sequence to trigger expressions that are unrelated but defined on the same class.

  3. Expression Engine cannot call a Java CF explicitly. However, changes to the target property due to an expression will be reflected in the custom functions that are defined as afterDB triggers (not beforeDB Triggers).

Simple Regular Expression

Expression:

This is an example of a simple expression:

Requirement:

To evaluate the risk score for the items in the Item class based on the predefined risk factors of the items, as in this table.

Class

Risk Factors For The Organization

Properties

Health/Safety Hazard, High Field Failures, Low PPM Test Fields, Low Supplier Quality, Package Change, and Technology Decline

Use In Search

Risk Score

This table describes the variables to be defined for the corresponding properties:

For This Property Define This Variable

Health/Safety Hazard

HealthSafety

High Field Failures

HighFieldFail

Low PPM Test Fields

LowPPM

Low Supplier Quality

LowSupp

Package Change

PackChange

Technology Decline

TechDecline

Computation:

Risk Score = retValue (where Risk Score is the target property)

The expression in this diagram computes the total risk score for the items in the Item class based on the risk factors of each item.

Result

Item Number Total Risk Score

10201

30

Expression With Pointed Property

Expression:

 

Sub-Expression

A Sub-Expression is a script used to calculate the value of a variable in a regular expression.

For example, A = B + C is the regular expression. The value of B is derived from the sub-expression B = E + F, where, B, C, E, and F are variables you define.

For more information on sub expressions, see Creating Expressions With Sub-Expressions. <create link here>

This is an example of a sub-expression:

Requirement:

To calculate the total cost of an assembly in United States dollars (US $) local currency, as in this table.

Class

Assembly Item

Properties

Quantity, Part Cost (pointed property to the Item class), Assembly
Cost, Locale Currency

Target Property

Assembly Cost

This table describes the variables to be defined for the corresponding properties:

For This Property Define This Variable

Quantity

Quantity

Part Cost

PartCost

Assembly Cost

AssemblyCost

Local Currency

LocaleCurrency

NA

TotalCost

Computation:

  • Main expression:
    This expression evaluates the total assembly cost based on the result returned by the TotalCost variable and the valid value of the local currency.

    AssemblyCost=TotalCost * LocalCurrency

  • Secondary expression:

    TotalCost=Quantity * PartCost
    Secondary expression computes these values:

Quantity 1 * PartCost 1
Quantity 2 * PartCost 2
Quantity 3 * PartCost 3
Quantity 4 * PartCost 4
Quantity 5 * PartCost 5
Quantity 6 * PartCost 6
...
...
...
Quantity n * PartCost n

  • Multi Value Parser script
    The Multi Value Parser Script evaluates the value of the TotalCost. It adds the product of Quantity and Part Cost.

    TotalCost = (Quantity 1 * Part Cost 1) + (Quantity 2 * Part Cost 2)+ (Quantity 3 * Part Cost 3)+ (Quantity 4 * Part Cost 4)+ (Quantity 5 * Part Cost 5)+ (Quantity 6 * Part Cost 6)+... (Quantity n * Part Cost n)

This diagram represents the computation of the Assembly Cost:

Class Copy Manager

Use the Class Copy Manager to edit a record in a class based on the evaluation and the computed result of an expression defined for another class.
The Class Copy Manager includes:

  • Copy Expression class

  • Property Mapping class

  • Pointer Mapping class

  • Property Setting class

Copy Expression Class

The Copy Expression class is used to specify the source and target classes. A record is edited in the target class based on the result returned by the expression defined for the source class.

This table describes the properties associated with the Copy Expression class:

Property Name Description

Source Class

Specifies the source class.

Target Class

Specifies the target class. A record is inserted, updated or deleted from this class.

Expression

The pointer to the expression that is executed when a value is edited in the source class.

Operation

The type of action to be performed on the target class when the expression is executed. Select Insert/Update or Delete from the Values - Operation dialog box.

Expression Return Value

The evaluated value of the expression from the source class, based on which a particular operation is performed.

Copy Expression

Use the classes under the Class Copy Manager folder to execute Copy expressions. For more information on Copy Expressions see, Creating Copy Expressions. <create link here>

What is a Copy Expression

A Copy expression enables you to insert, update, or delete a record from a target class based on the evaluation of an expression from the source class. You can also assign a particular value for the target property based on the evaluation of expression defined on another (source) class.

Why Use Copy Expressions.

You can use Copy expression to update the preferred supplier list based on the estimated preferred items list.

Features of Copy Expressions

Using a Copy expression you can:

  • Copy a record from a source class to target class.

  • Map the properties of the source class and the target class to edit the properties of the target class.

  • Map the pointers of the source class and the target class to edit the pointers of the target class.

  • Assign a value for a property in the target class which becomes the default value for all the records in the target class.

Note: If the property and pointer labels are same in both the source and target classes, you need not map the properties and pointers from the source class to the target class. The Logical Data Definitions (LDDs) of the source class and target class should match. For example, if the source class property is text type, the target class property should also be text type.

This is an example of Copy Expression.

Requirement:

Insert, update, or delete items in the Preferred Item class based on the preference score of the items in the Items class.

Available Data:

Class         Item, Preferred Item

Property     Preference Score

This table describes the variables to be defined for the corresponding properties:

For This Property Define This Variable

Preference Score

PreferenceScore

 

When the five records of the Item class are edited, the expression attached to the class is executed and an insert, update, or delete operation is initiated on the Preferred Item class based on the criteria specified in the expression.

Change Event Expression

These are the features of a Change Event expression:

  • Change Event Expression is used to trigger an CES alert.

  • A Change Event expression can also be made inactive by setting the isActive property in the Expression class to no.