Making a Property Mandatory or Optional Following an Update to Another Property

This document provides information on how to use business logic to make a property (field) mandatory or optional when the value in a different property is updated.

The process described below demonstrates how to add a script to a data class to set the value of one property (MYPROP2) to mandatory or optional when the value of a different property (MYPROP1) is set.

  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 fields. It is automatically generated using the class code and the script type. You can also enter a unique code for your script.
    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 enter the running order code for your script.
  3. Click the Actions button of your script, and click Processing editor. Enter the source code below.
    $PROPERTIESCase CURPROWhen "MYPROP1" : Gosub MYPROP1EndcaseReturn# Actions for "MYPROP1"$MYPROP1Case ACTIONWhen "PROPAGATE" : Gosub MYPROP1_PROPAGATEEndcaseReturn# Set MYPROP2 to Mandatory or not, depending on value of MYPROP1$MYPROP1_PROPAGATEIf THIS.MYPROP1 = CST_AYESASTATUS = fmet THIS.ASETATTRIBUTE("MYPROP2","$isMandatory","true")ElseASTATUS = fmet THIS.ASETATTRIBUTE("MYPROP2","$isMandatory","false")EndifReturn
  4. Save your script.
  5. Save and validate your data class.