Skip to main content

Referring to Fields from ObjectScript

Referring to Fields from ObjectScript

Within a class definition, there are several places that may include ObjectScript code used in SQL. For example, SQL computed field code and trigger code is executed from within SQL. In these cases, there is no concept of a current object, so it is not possible to use dot syntax to access or set data within a specific instance. Instead, you can access the same data as fields within the current row using field syntax.

To reference a specific field of the current row, use the {fieldname} syntax where fieldname is the name of the field.

For example, the following code checks if the salary of an employee is less than 50000:

 If {Salary} < 50000 {
    // actions here...
 }
Note:

In UPDATE trigger code, {fieldname} denotes the updated field value. In DELETE trigger code, {fieldname} denotes the value of the field on disk.

To refer to the current field in a SQL computed field, use the {*} syntax.

For example, the following code might appear in the computed code for a Compensation field to compute its value based on the values of Salary and Commission fields:

 Set {*} = {Salary} + {Commission}

For trigger-specific syntax, see Special Trigger Syntax.

FeedbackOpens in a new tab