Changing the Properties of a Data Class Using a Standard Method

This document provides information on how to use a standard method to change the properties (fields) of a data class from another data class.

The development process described below demonstrates how to add a simple script to a data class (MYCLASS2) to update the properties (MYPROP1) of a different data class (MYCLASS1).

  1. Open your data class (MYCLASS2).
  2. In the Methods block of the Methods tab:
    1. Enter a new method code (MYMETH1) in the Code field.
    2. Enter a description for the method in the Description field.
    3. Select the appropriate return type in the Return type field.
    4. Select the Operation check box. This automatically generates the keys in the Keys block.
  3. In the Parameters block, enter the parameters (MYPARAM1) that need to be passed.
  4. 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.
  5. Click the Actions button of your script, and click Processing editor. Enter the source code.
    Note: This example shows how to update the property (MYPROP1) in data class MYCLASS1 from data class MYCLASS2.
    # Structure MYCLASS2###########################################METHODS ###########################################$METHODSCase CURPTHWhen ""Case ACTIONWhen "AINSERT_AFTER" Gosub AINSERT_AFTER # Update after insertEndcase EndcaseReturn# Update properties in MYCLASS1 using MYCLASS2$AINSERT_AFTER# Declaration new instance of MYCLASS1 data classLocal Instance MYCLASS Using C_MYCLASS1MYCLASS = NewInstance C_MYCLASS1 AllocGroup NullASTATUS=fmet MYCLASS.AREAD(this.KEY_VALUE)If ASTATUS<>[V]CST_AOKASTATUS = fmet THIS.ASETERROR ("", "Not updated.", [V]CST_AERROR) ARET_VALUE= CST_AFALSEElse# change property values and updateMYCLASS.MYPROP1 = this.MYPROP2ASTATUS=fmet MYCLASS.AUPDATEIf ASTATUS<>[V]CST_AOKASTATUS = fmet THIS.ASETERROR ("", "Not updated.", [V]CST_AERROR) ARET_VALUE= CST_AFALSEElseARET_VALUE= CST_ATRUEEndifEndif# Free instancesFreeGroup MYCLASSReturn
  6. Save your script.
  7. Save and validate your data class.