The AL developer preview is still evolving with frequent updates. Follow us on the Dynamics NAV Team Blog for the announcements.
GET Method (RecordRef)
Gets a record based on the ID of the record.
[Ok :=] RecordRef.GET(RecordID)
The RecordRef that refers to a table.
The RecordID that contains the table number and the primary key of the table and is used to identify the record that you want to get.
Property Value/Return Value
true if the record was found; otherwise, false.
If you omit this optional return value and if the record cannot be found, then a run-time error occurs. If you include the return value, you must handle any errors.
This method always uses the primary key for the table. It ignores any filters that are set, except security filters. Security filters are applied or ignored based on the Security Filter Mode. The current key and filters are not changed after you call this method. .
The following example opens the Customer table with the RecordRef variable, RecRef. The code assigns the first field in the table, which is the No. field, to MyFieldRef variable. The variable is assigned a value of 30000 by using the FIELD Method (RecordRef). The RECORDID Method (RecordRef) retrieves the record ID of the record that has a value of 30000 in the No. field. The GET method then uses the RecID variable then to retrieves the record. This example requires that you create the following global variables.
RecRef.OPEN(DATABASE::Customer); MyFieldRef := RecRef.FIELD(1); MyFieldRef.VALUE := '30000'; IF RecRef.FIND('=') THEN BEGIN RecID := RecRef.RECORDID; RecRef.GET(RecID); END