How to hide or make a property visible from an update to a different property
This ‘How-to’ provides information on how to use business logic to hide a property (field), or make a property visible when the value in a different property is updated.
The following development process demonstrates how to add a simple script to a representation class to hide a property (MYPROP2) when the value in a different property (MYPROP1) is set.
Open your representation class.
Select the General tab > Scripts block, and set the following field values:
Type: Select a type appropriate for your script.
Scripts: Accept the displayed default code. This is automatically generated using the class code and script type. Alternatively, enter a unique code for your script.
Running order: Accept the displayed numeric value. This is automatically generated to control the order in which the '$PROPERTIES' and '$METHODS' labels are called in the event. Alternatively, enter the running order code for your script.
To add your script, right-click the Scripts code and select Processing editor from the selection menu. 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 hidden or visible, depending on value of MYPROP1
$PROP1_PROPAGATE
If THIS.MYPROP1 = CST_AYES
ASTATUS = fmet THIS.ASETATTRIBUTE("MYPROP2","$isHidden","true")
Else
ASTATUS = fmet THIS.ASETATTRIBUTE("MYPROP2","$isHidden","false")
Endif
Return
4. Save your script.
5. Save and validate your representation class.