Record.Get procedure arguments
Record.Get() retrieves a record by primary key. The arguments must match the target table’s primary key fields in number, order, and type. When too few arguments are provided, the platform does not reject the call:
Getdoesn’t require specifying all fields of the key in the call; any omitted field is treated as default value (for example,''for text/code,falsefor boolean). You can only omit from the end of the key, not a field in the middle of a key.
— Record.Get([Any,…]) Method on Microsoft Learn
A call like ItemVariant.Get('10000') on a table whose primary key is (“Item No.”, Code) silently looks for the record where "Item No." is '10000' and Code is ''. That record almost certainly does not exist, and if it does, it is the wrong one. When an argument has a type that cannot be implicitly converted to the primary key field type, the call fails with a runtime error.
Match each argument to the corresponding primary key field.
Example
procedure GetItemVariant()
var
ItemVariant: Record "Item Variant";
begin
ItemVariant.Get('10000'); // Record.Get procedure arguments [PC0013]
end;The “Item Variant” table has a two-field primary key (“Item No.”, Code). Provide both values:
procedure GetItemVariant()
var
ItemVariant: Record "Item Variant";
begin
ItemVariant.Get('10000', 'BLUE');
end;When the diagnostic is reported
- Insufficient arguments: fewer arguments than primary key fields. The platform fills default values for omitted trailing fields, which retrieves the wrong record or fails silently.
- Too many arguments: more arguments than primary key fields.
- Type mismatch: an argument’s type does not match the corresponding primary key field and cannot be implicitly converted.
Exception
Tables with a single primary key field of type Code using the singleton pattern (e.g., “Company Information”) may call .Get() without arguments:
procedure GetCompanyInformation()
var
CompanyInformation: Record "Company Information";
begin
CompanyInformation.Get();
end;When a RecordId is passed as the sole argument, the diagnostic is not raised — the primary key values are resolved at runtime:
procedure GetItemVariant(MyRecordId: RecordId)
var
ItemVariant: Record "Item Variant";
begin
ItemVariant.Get(MyRecordId);
end;Implicit conversions
The analyzer allows these implicit type conversions when checking arguments:
Integer→Option,BigIntegerBigInteger→DurationCode↔Text- String literals →
Text,Code
Integer to Enum
To pass an Integer where the primary key expects an Enum, use FromInteger:
procedure GetSalesHeader(DocumentTypeAsInteger: Integer; DocumentNo: Code[20])
var
SalesHeader: Record "Sales Header";
begin
SalesHeader.Get("Sales Document Type".FromInteger(DocumentTypeAsInteger), DocumentNo);
end;Enum to Option
To pass an Enum where the primary key expects an Option, use AsInteger():
procedure MyProcedure(MyObjectType: Enum MyObjectType; ObjectId: Integer)
var
AllObjWithCaption: Record AllObjWithCaption;
begin
AllObjWithCaption.Get(MyObjectType.AsInteger(), ObjectId);
end;AsInteger() makes the conversion explicit, preventing accidental Enum-to-Option mismatches.
See also
- Get, Find, and Next methods on Microsoft Learn