Record.SetLoadFields Method

Sets the fields to be initially loaded when the record is retrieved from its data source. This will overwrite fields previously selected for initial load.

Syntax

[Ok := ]  Record.SetLoadFields([Fields: Any,...])

Parameters

Record
 Type: Record
An instance of the Record data type.

Fields
 Type: Any
The FieldNo's of the fields to be loaded.

Return Value

Ok
 Type: Boolean
true if all fields are selected for subsequent loads; otherwise, false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.

Remarks

Calling SetLoadFields on a record without passing any fields will reset the fields selected to load to the default, where all readable normal fields are selected for load.

This method is part of the partial records capability for improving performance. For more information, see Using Partial Records.

Example

This example uses the SetLoadFields method to speedup the calculation of the mean for values of the Standard Cost field in the Item table. Instead of loading all fields, only the Standard Cost is loaded. The other fields aren't needed for the calculation, so they're not loaded.

procedure ComputeArithmeticMean(): Decimal;
var
    Item: Record Item;
    SumTotal: Decimal;
    Counter: Integer;
begin
    Item.SetLoadFields(Item."Standard Cost");
    if Item.FindSet() then begin
        repeat
            SumTotal += Item."Standard Cost";
            Counter += 1;
        until Item.Next() = 0;
        exit(SumTotal / Counter);
    end;
    end;

See Also

Using Partial Records
Record Data Type
Getting Started with AL
Developing Extensions