Edit

Share via


RecordRef.SetLoadFields([Integer,...]) Method

Version: Available or changed with runtime version 6.0.

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 := ]  RecordRef.SetLoadFields([Fields: Integer,...])

Parameters

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

[Optional] Fields
 Type: Integer
The FieldNo's of the fields to be loaded.

Return Value

[Optional] 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 recordref without passing any fields will reset the fields selected to load to the default, where all readable normal fields are selected for load.

It is not necessary to include the following fields, because they are always selected for loading: Primary key, SystemId, and data audit fields (SystemCreatedAt, SystemCreatedBy, SystemModifiedAt, SystemModifiedBy).

Note

Only fields of FieldClass = Normal are supported as input values for the Fields parameter. If fields of FieldClass = FlowFilter or FieldClass = FlowField are passed, the return value will be false if observed; otherwise, a runtime error will occur.

This method is part of the partial records capability for improving performance. Learn more in Using partial records.

Example

This code example uses the SetLoadFields method to speedup the calculation of the mean for values in a table field. The other fields aren't needed for the calculation, so they're not loaded.

procedure ComputeAritmeticMean(MyRecordRef: RecordRef; FieldNo: Integer): Decimal
var
    SumTotal: Decimal;
    Counter: Integer;
begin
    MyRecordRef.SetLoadFields(FieldNo);
    if MyRecordRef.FindSet() then begin
        repeat
            SumTotal := MyRecordRef.Field(FieldNo).Value;
            Counter += 1;
        until MyRecordRef.Next() = 0;
        exit(SumTotal / Counter);
    end;
end;

Using Partial Records
RecordRef Data Type
Get Started with AL
Developing Extensions