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).

How it Works

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: * Access the Old Variable Value within the CFL using the local variable OldValue. * Access the New Variable Value within the CFL using the local variable NewValue. * Effectively cancel the change by assigning NewValue := OldValue; * Change what value actually gets saved by assigning it to NewValue.


Limit Changes based on Security Rights

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 GESHI_QUOTsidNewGESHI>_)

''   AND (TransHeader.TransactionType = 1) // allow for Orders (1)
   AND NOT HasSecurityRight(1, 20035)  // 1 = Edit, 20035 = Journal Entry
THEN  NewValue := OldValue

You could leave a comment if you were logged in.