Gets a string that contains the primary key of the current record.

String := RecordRef.GETPOSITION([UseNames])

Parameters

RecordRef

Type: RecordRefThe RecordRef that refers to the record for which you want to know the primary key.
UseNames

Type: BooleanIndicates whether a reference to the field name or the field number should be returned.If this parameter is true (default) or if it is empty, the returned string contains references to field names in the table with which the record is associated. If the parameter is false, the returned string contains references to field numbers in the table with which the record is associated.This parameter is optional.

Property Value/Return Value

Type: Text or code

The name or number of the field that contains the primary key.

The string has the same format as the SourceTableRecord Property on a page.

Remarks

This function works just like the GETPOSITION Function (Record).

Example

The following example opens the Customer table as a RecodRef that is named RecRef. The RecordRef variable uses the GETPOSITION function to retrieve the position of the primary key. The UseNames parameter is set to true so the name of the field that contains the primary key is returned. If you set UseNames to false, the number of the field is returned. This example requires that you create the following variables in the C/AL Globals window.

Variable name DataType

RecRef

RecordRef

varPrimaryKey

Text

Text constant ENU value

Text000

The primary key is: %1.

  Copy Code
RecRef.OPEN(DATABASE::Customer);
varPrimaryKey := RecRef.GETPOSITION(TRUE);
MESSAGE(Text000, varPrimaryKey);

See Also