RecordRef Data Type

References a record in a table.

The following methods are available on instances of the RecordRef data type.

Method name Description
Open(Integer [, Boolean] [, String]) Causes a RecordRef variable to refer to a table, which is identified by its number in a particular company.
Close() Closes the current page or table.
GetTable(Record) Gets the table of a Record variable and causes the RecordRef to refer to the same table.
SetTable(Record) Sets the table to which a Record variable refers as the same table as a RecordRef variable.
Duplicate() Duplicates the table that contains the RecordRef.
IsTemporary() Determines whether a RecordRef refers to a temporary table.
CurrentCompany() Gets the current company of a database table referred to by a RecordRef.
Get(RecordId) Gets a record based on the ID of the record.
Find([String]) Finds a record in a table based on the values stored in the key fields.
Next([Integer]) Steps through a specified number of records and retrieves a record.
FindFirst() Finds the first record in a table based on the current key and filter.
FindLast() Finds the last record in a table based on the current key and filter.
FindSet([Boolean] [, Boolean]) Finds a set of records in a table based on the current key and filter. FINDSET can only retrieve records in ascending order.
Reset() Removes all filters, including any special filters set by the MARKEDONLY method (Record) and changes the current key to the primary key. Also removes any marks on the record and clears any AL variables on the record.
Ascending([Boolean]) Changes or checks the order in which a search through the table that is referred to by RecordRef will be performed.
LockTable([Boolean] [, Boolean]) Locks a table to protect it from write transactions that conflict with each other.
Count() Counts the number of records that are in the filters that are currently applied to the table referred to by the RecordRef.
IsEmpty() Determines whether any records exist in a filtered set of records in a table.
CountApprox() Gets an approximate count of the number of records in the table
CurrentKey() Gets the current key of the table referred to by the RecordRef. The current key is returned as a string.
CurrentKeyIndex([Integer]) Gets or sets the current key of the table referred to by the RecordRef. The current key is set or returned as a number. This first key = 1, and so on. If RecordRef does not have an active record, CURRENTKEYINDEX will return -1. If this value is then passed to KEYINDEX, an index out of bounds error will occur. Therefore it is important to implement a check of the RecordRef parameter.
GetPosition([Boolean]) Gets a string that contains the primary key of the current record.
SetPosition(String) Sets the fields in a primary key on a record to the values specified in the String parameter. The remaining fields are not changed.
Number() Gets the table ID (number) of the table that contains the record that was referred to by the RecordRef.
Name() Identifies the name of the table
Caption() Gets the caption of the table that is currently selected. Returns an error if no table is selected.
RecordId() Gets the RecordID of the record that is currently selected in the table. If no table is selected, an error is generated.
ChangeCompany([String]) Redirects references to table data from one company to another.
Init() Initializes a record in a table.
Insert() Inserts a record into a table without executing the code in the OnInsert trigger.
Insert(Boolean) Inserts a record into a table.
Insert(Boolean, Boolean) Inserts a record into a table.
Modify([Boolean]) Modifies a record in a table.
Delete([Boolean]) Deletes a record in a table.
DeleteAll([Boolean]) Deletes all records in a table that fall within a specified range.
ReadPermission() Determines if you can read from a table.
WritePermission() Determines if you can write to a table.
ReadConsistency() Gets a value indicating whether read consistency is enabled.
RecordLevelLocking() Gets a value indicating whether record level locking is enabled.
AddLink(String [, String]) Adds a link to a record in a table.
DeleteLink(Integer) Deletes a specified link from a record in a table.
DeleteLinks() Deletes all of the links that have been added to a record.
CopyLinks(Record) Copies all the links from a particular record.
CopyLinks(RecordRef) Copies all the links from a particular record.
CopyLinks(Variant) Copies all the links from a particular record.
HasLinks() Determines whether a record contains any links.
FieldCount() Gets the number of fields in the table that are currently selected or returns the number of fields that have been defined in a key. Returns an error if no table or no key is selected.
Field(Integer) Gets a FieldRef for the field that has the number FieldNo in the table that is currently selected. If no field has this number, the method returns an error.
FieldExist(Integer) Determines if the field that has the number FieldNo exists in the table that is referred to by the RecordRef. Returns an error if no table is currently selected.
FieldIndex(Integer) Gets the FieldRef of the field that has the specified index in the table that is referred to by the RecordRef.
KeyCount() Gets the number of keys that exist in the table that is referred to by the RecordRef. Returns an error if no table is selected.
KeyIndex(Integer) Gets the KeyRef of the key that has the index specified in the table that is currently selected. The key can be composed of fields of any supported data type. Data types that are not supported include BLOBs, FlowFilters, variables, and functions. If the sorting key is set to a field that is not part of a key, then the KEYINDEX is -1.
GetFilters() Determines which filters have been applied to the table referred to by the RecordRef.
GetView([Boolean]) Returns a string that describes the current sort order, key, and filters on a table.
SetView(String) Sets the current sort order, key, and filters on a table.
HasFilter() Determines whether a filter has been applied to the table that the RecordRef refers to.
SetRecFilter() Sets a filter on a record that is referred to by a RecordRef.
FilterGroup([Integer]) Changes the filter group that is being applied to the table. You can also use this method to return the number of the current filtergroup. You cannot return the number of the filtergroup and set a new filtergroup at the same time.
SetPermissionFilter() Applies the user's security filter to the referenced record. The security filter is combined with any other filters that are placed on the record with SetFilter or SetRange. The combined filter will not include any records outside the range of the security filter and this will prevent a runtime permission error from occuring when the record is read. If the permission filter is not set, an error can occur if you attempt to read a record that is outside the range of the user's security filter.
Rename(Any [, Any,...]) Changes the value of a primary key in a table.
SecurityFiltering([SecurityFilter]) Gets or sets how security filters are applied to the RecordRef.
SystemIdNo() Gets the field number that is used by the SystemId field. The SystemId field is a system field that the platform adds to all table objects.

The RecordRef object can refer to any table in the database. Use the OPEN method to use the table number to select the table that you want to access, or use the GETTABLE method to use another record variable to select the table that you want to access.

If one RecordRef variable is assigned to another RecordRef variable, then they both refer to the same table instance.

See Also

Getting Started with AL
Developing Extensions