Disabling or Making a Property Editable Following an Update to a Different Property

This document provides information on how to use business logic to disable a property (field), or to make it editable when the value of a different property is updated.

The process described below demonstrates how to add a script to a representation class to set the value of one property (MYPROP2) to "disabled" or to "editable", as appropriate, when the value in a different property (MYPROP1) is set.

  1. Open your representation 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 File field. It is automatically generated using the class code and the script type. You can also manually enter a unique code for your script.
    3. Accept the numeric value displayed in the 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 code for your script.
  3. To add your script, click the Actions button of your script, and click Processing editor. Enter the following code:
    $PROPERTIES
      Case CURPRO
        When "MYCLASS.MYPROP1"    : Gosub MYPROP1
      Endcase
    Return
    # Actions for "MYPROP1"
    $MYPROP1
      Case ACTION
        When "PROPAGATE" : Gosub PROP1_PROPAGATE
      Endcase
    Return
    # Set MYPROP2 to Disabled or editable, depending on value of MYPROP1
    $PROP1_PROPAGATE
      If THIS.MYPROP1 = CST_AYES
        ASTATUS = fmet THIS.ASETATTRIBUTE("MYPROP2","$isDisabled","true")
      Else
        ASTATUS = fmet THIS.ASETATTRIBUTE("MYPROP2","$isDisabled","false")
      Endif
    Return
  4. Save your script.
  5. Save and validate your representation class.