The following example creates a calculated field, using the Field’s beforeGetValue event to calculate the total price from the quantity and price per item for each line item:

q = new Query()

q.sql := "select * from LINEITEM"

q.active := true

c = new Field()

c.fieldName := "Total"

q.rowset.fields.add(c)

c.beforeGetValue := {||this.parent["Quantity"].value * this.parent["PricePer"].value}

Because this refers to the Field object itself, this.parent refers to the fields array, through which you can access the other field objects.