GetLastRecord()
Summary
Gets the last record in a view or selection set based on a sort order.
Syntax
record_handle = GetLastRecord(string view_set, array sort_order)
| Argument | Contents |
|---|---|
| view_set | The view and the set of records to consider |
| sort_order | An array indicating the desired sort order, or null for natural order. The array is an array of field name-order pairs: |
| Element | Type | Contents |
|---|---|---|
| 1 | String | The name of the field |
| 2 | String | "Ascending" or "Descending" |
Returns
The record handle (string) for the last record in the input view and set when sorted as specified; or null if the input view and set have no records.
Notes
-
The returned record is also set as the current record.
-
GetLastRecord() performs any necessary indexing.
-
The first pair in the sort_order array specifies the primary sort order. The second pair, if present, specifies the secondary sort order, and so on.
Example
first_emp = GetLastRecord("Employees", {{"LNAME", "Ascending"}})
first_emp = GetLastRecord("Employees", {
{"LNAME", "Ascending"},
{"FNAME", "Ascending"}
})
Error Codes
| Error Type | Meaning |
|---|---|
| NotFound | The specified view or set does not exist; or some field in the sort_order array does not exist |
See Also
| Function | Summary |
|---|---|
| GetFirstRecord() | Finds the first record in a view or selection set based on a sort order |
| GetNextRecord() | Gets the next record in a view or selection set based on a sort order |
| GetPrevRecord() | Finds the previous record in a view or selection set based on a sort order |
| GetRecord() | Gets the record handle of the current record of a view |
| GetRecords() | Gets an array of record handles for a selection set |
| LocateRecord() | Locates a record based on the value of a field |
| SetRecord() | Sets the current record of a view |