Changing the Value of a Property From Another Property

This document provides information on how to change the value of a property (field) when the value of another property is updated.

The process described below demonstrates how to add a simple script to a data class to update the value of property MYPROP2 when the value of property MYPROP1 changes.

  1. Open your data class.
  2. In the Scripts block of the General tab:
    1. Select the appropriate type for your script in the Type field.
    2. Accept the default code displayed in the Scripts field. It is automatically generated using the class code and the script type. You can also manually enter a unique code.
    3. Accept the numeric value displayed in the Running order field. It is automatically generated to control the order in which the $PROPERTIES and $METHODS labels are called in the event. You can also manually enter the running order.
  3. Click the Actions button of your script, and click Processing editor. Enter the source code.
    # Properties for MYCLASS
    $PROPERTIES
      Case CURPRO
        When "MYPROP1"    : Gosub MYPROP1
      Endcase
    Return
    # Action to be carried out when MYPROP1 is updated = automatically set MYPROP2 to active NO
    $MYPROP1
      Case ACTION
        # Set MYPROP2 to active NO
        When "PROPAGATE"
          this.MYPROP2 = CST_ANO
      Endcase
    Return
    Note: In this example, the value for property MYPROP2 is set to "NO" when MYPROP1 is changed. However, the principle and format can be used for any property (field) type.
  4. Save your script.
  5. Save and validate your data class.