The AL developer preview is still evolving with frequent updates. Follow us on the Dynamics NAV Team Blog for the announcements.

GETPOSITION Method (RecordRef)

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


String := RecordRef.GETPOSITION([UseCaptions])  


Type: RecordRef

The RecordRef that refers to the record for which you want to know the primary key.

Type: Boolean

Indicates whether a reference to the field caption or the field number should be returned.

The UseCaptions parameter is optional. If it is set to true (default value) or if it is empty, then the returned string contains references to field captions in the table with which the record is associated. If the parameter is set to false, then field numbers are used instead.

Property Value/Return Value

Type: Text or code

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


This method works just like the GETPOSITION Method (Record).


The following example opens the Customer table as a RecodRef that is named RecRef. The RecordRef variable uses the GETPOSITION method to retrieve the position of the primary key. The UseCaptions parameter is set to true so the caption of the field that contains the primary key is returned. If you set UseCaptions to false, the number of the field is returned. This example requires that you create the following global variables.

Variable name DataType
RecRef RecordRef
varPrimaryKey Text
Text constant ENU value
Text000 The primary key is: %1.

varPrimaryKey := RecRef.GETPOSITION(TRUE);  
MESSAGE(Text000, varPrimaryKey);  

See Also

RecordRef Data Type