GETPOSITION Function (RecordRef)
Gets a string that contains the primary key of the current record.
String := RecordRef.GETPOSITION([UseCaptions])
The RecordRef that refers to the record for which you want to know the primary key.
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 function works just like the GETPOSITION Function (Record).
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 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 variables in the C/AL Globals window.
|Text constant||ENU value|
|Text000||The primary key is: %1.|
RecRef.OPEN(DATABASE::Customer); varPrimaryKey := RecRef.GETPOSITION(TRUE); MESSAGE(Text000, varPrimaryKey);