$previous
Return the value of the field in the previous occurrence.
$previous(
Field)
Example: vInvoice = $previous(INVOICENUM) + 1
Parameters
Parameter | Data Type | Description |
---|---|---|
Field | String | Field name; can optionally contain a
qualified field name, for example MYFLD.MYENT . |
Return Values
- Value of Field in the previous occurrence.
- Empty string ("") is returned if there is no previous occurrence.
Use
Allowed in all component types.
Description
The $previous function allows you to refer to the contents of a field in the previous occurrence. Use it to:
- Copy contents of a field to another field or variable.
- Perform calculations.
- Make Boolean comparisons.
Note: This function is not always the most efficient way of referring to a field in the previous occurrence. This is particularly true when the field referred to by $previous is part of an occurrence that has already been active.
If the field forms part of an occurrence that has already been active, it is often preferable to store the contents of that field in a variable before moving to the previous occurrence, then referring to the variable. This usually costs less processing power. Use the getFocus trigger to do this. If you are printing, you could also use the leavePrinted trigger.
You can test for an empty string with:
if ($previous(NAME) = "")
Using $previous
The following example generates a new invoice number using the previous number as a base:
invoiceno = $previous(INVOICENO) + 1