RecordRef Data Type

Version: Available or changed with runtime version 1.0.

References a record in a table.

Instance methods

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

Method name Description
AddLink(Text [, Text]) Adds a link to a record in a table.
AddLoadFields([Integer,...]) Specifies additional fields to be initially loaded when the record is retrieved from its data source. Subsequent calls to AddLoadFields will not overwrite fields already selected for the initial load.
AreFieldsLoaded(Integer,...) Checks whether the specified fields are all initially loaded.
Ascending([Boolean]) Changes or checks the order in which a search through the table that is referred to by RecordRef will be performed.
Caption() Gets the caption of the table that is currently selected. Returns an error if no table is selected.
ChangeCompany([Text]) Redirects references to table data from one company to another.
ClearMarks() Removes all the marks from a record.
Close() Closes the current page or table.
Copy(var Record [, Boolean]) Copies a specified record's filters, views, automatically calculated FlowFields, marks, fields, and keys that are associated with the record from a table or creates a reference to a record.
Copy(RecordRef [, Boolean]) Copies a specified record referece's filters, views, automatically calculated FlowFields, marks, fields, and keys that are associated with the record from a table or creates a reference 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.
Count() Counts the number of records that are in the filters that are currently applied to the table referred to by the RecordRef.
CountApprox() Gets an approximate count of the number of records in the table
CurrentCompany() Gets the current company of a database table referred to by a RecordRef.
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.
Delete([Boolean]) Deletes a record in a table.
DeleteAll([Boolean]) Deletes all records in a table that fall within a specified range.
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.
Duplicate() Duplicates the table that contains the RecordRef.
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.
FieldCount() Gets the number of fields in the table that is 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.
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.
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.
Find([Text]) Finds a record in a table based on the values stored in the key fields.
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]) Finds a set of records in a table based on the current key and filter. FINDSET can only retrieve records in ascending order.
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.
Get(RecordId) Gets a record based on the ID of the record.
GetBySystemId(Guid) Gets a record based on the ID of the record. The RecordRef must already be opened.
GetFilters() Determines which filters have been applied to the table referred to by the RecordRef.
GetPosition([Boolean]) Gets a string that contains the primary key of the current record.
GetTable(Record) Gets the table of a Record variable and causes the RecordRef to refer to the same table.
GetView([Boolean]) Returns a string that describes 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.
HasLinks() Determines whether a record contains any links.
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.
IsDirty() Gets a boolean value that indicates whether the current in-memory instance of a record or filtered set of records has changed since being retrieved from the database.
IsEmpty() Determines whether any records exist in a filtered set of records in a table.
IsTemporary() Determines whether a RecordRef refers to a temporary table.
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.
LoadFields(Integer,...) Accesses the table's corresponding data source and loads the values of the specified fields on the record.
LockTable([Boolean] [, Boolean]) Starts locking on a table to protect it from write transactions that conflict with each other.
Mark([Boolean]) Marks a record. You can also use this method to determine whether a record is marked.
MarkedOnly([Boolean]) Activates a special filter. After you use this function, your view of the table includes only records marked by the Mark method (RecordRef).
Modify([Boolean]) Modifies a record in a table.
Name() Identifies the name of the table
Next([Integer]) Steps through a specified number of records and retrieves a record.
Number() Gets the table ID (number) of the table that contains the record that was referred to by the RecordRef.
Open(Integer [, Boolean] [, Text]) Causes a RecordRef variable to refer to a table, which is identified by its number in a particular company.
ReadConsistency() Gets a value indicating whether read consistency is enabled.
ReadIsolation([IsolationLevel]) Gets or sets the read isolation level.
ReadPermission() Determines if you can read from a table.
RecordId() Gets the RecordID of the record that is currently selected in the table. If no table is selected, an error is generated.
RecordLevelLocking() Gets a value indicating whether record level locking is enabled.
Rename(Any [, Any,...]) Changes the value of a primary key in a table.
Reset() Removes all filters, including any special filters set by the MarkedOnly method (Record), changes fields select for loading back to all, and changes the current key to the primary key. Also removes any marks on the record and clears any AL variables defined on its table definition.
SecurityFiltering([SecurityFilter]) Gets or sets how security filters are applied to the RecordRef.
SetLoadFields([Integer,...]) Sets the fields to be initially loaded when the record is retrieved from its data source. This will overwrite fields previously selected for initial load.
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.
SetPosition(Text) Sets the fields in a primary key on a record to the values specified in the String parameter. The remaining fields are not changed.
SetRecFilter() Sets a filter on a record that is referred to by a RecordRef.
SetTable(Record) Sets the table to which a Record variable refers as the same table as a RecordRef variable.
SetTable(Record, Boolean) Sets the table to which a Record variable refers as the same table as a RecordRef variable.
SetView(Text) Sets the current sort order, key, and filters on a table.
SystemCreatedAtNo() Gets the field number that is used by the SystemCreatedAt field. The SystemCreatedAt field is a system field that the platform adds to all table objects.
SystemCreatedByNo() Gets the field number that is used by the SystemCreatedBy field. The SystemCreatedBy field is a system field that the platform adds to all table objects.
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.
SystemModifiedAtNo() Gets the field number that is used by the SystemModifiedAt field. The SystemModifiedAt field is a system field that the platform adds to all table objects.
SystemModifiedByNo() Gets the field number that is used by the SystemModifiedBy field. The SystemModifiedBy field is a system field that the platform adds to all table objects.
WritePermission() Determines if you can write to a table.

Remarks

The RecordRef object can refer to any table in the database, if the extension target in app.json doesn't conflict with the field/table scope. Example, an extension with target Cloud can't use RecordRef to access a table with scope OnPrem. 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

Get started with AL
Developing extensions