How to change the value of one property from an update to a different property

This ‘How-to’ provides information on how to change the value in one property (field) when the value in a different property is updated. The following development process demonstrates how to add a simple script to a Data class to set the value of one property (MYPROP2) when the value in a different property (MYPROP1) changes.

1) Open your Data class.

2) Select the General tab > Scripts block and set the following field values:

3) To add your script, right-click the Scripts code and select Processing editor from the selection menu. Enter the following 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: Although this example will set the value for the property MYPROP2 to NO when MYPROP1 is changed, the principle and format can be used for any property (field) type.

4) Save your script.

5) Save and validate your Data class.