=OnChange Event for Variables=
This new feature allows a user to establish CFL procedures that are executed when the value of variable changes (either by calculation or because it is set in CFL).
In variable setup (both globally and for an individual product), a new formula box is added to all variable types except Table and Image.
Action when value changes [___]fx]
The CFL code entered (if any) is executed whenever the variable value changes.
The code that the user enter is surrounded by code that is added when it calls. The result is to create “function” like capabilities that allow the user to access and possibly change the value. The CFL code that is actually run is similar to this code:
DECLARE OldValue := {oldvalue};
DECLARE NewValue := {newvalue};
NewValue;
The variable is assigned the value of the CFL statement, which will be NewValue, after the CFL code is executed. This structure allows the user to:
=Examples=
In this example, we prevent users from making any changes to the variable once it is a saved order unless they have a particular security right. It does that by resetting the new value back to the old value if they don't have permissions.
IF (TransHeader.StatusID "sidNew")
AND (TransHeader.TransactionType = 1) // allow for Orders (1)
AND NOT HasSecurityRight(1, 20035) // 1 = Edit, 20035 = Journal Entry
THEN NewValue := OldValue
ENDIF;
=See Also=