Editar

Compartir a través de


Record.CalcFields(Any [, Any,...]) Method

Version: Available or changed with runtime version 1.0.

Calculates the FlowFields in a record. You specify which fields to calculate by using parameters.

Syntax

[Ok := ]  Record.CalcFields(Field1: Any [, Field2: Any,...])

Parameters

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

Field1
 Type: Any

[Optional] Field2
 Type: Any

Return Value

[Optional] Ok
 Type: Boolean
true if the operation was successful; otherwise false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.

Remarks

FlowFields are virtual fields. The values in these fields are not saved in the table. This means that you must use either the CalcFields method or the SetAutoCalcFields Method (Record) to update them. For example, if you retrieve a record using the Find Method (Record) and Next Method (Record), the FlowFields in those records are set to zero (0). Then, when you call CalcFields, their values are updated.

When a FlowField is a direct source expression on a page or a report, the calculation is performed automatically.

You can also use the CalcFields method to retrieve binary large objects (BLOBs). For more information, see BLOB Data Type.

Dynamics 365 Business Central automatically maintains a count for all SIFT indexes. Therefore, SumIndexField Technology (SIFT) is used by default when the calculation method for a FlowField is Count or Average.

You can prevent the SIFT indexes from being updated by setting the MaintainSIFTIndex Property of the index in the base table to False. Then Business Central will traverse all records in the base table to perform the calculation instead of using SIFT. This can reduce the number of required SIFT indexes, which can improve performance. For more information, see SIFT and Performance.

In Dynamics 365 Business Central, an index is not required to support a certain sorting, but sorting without an index could lead to bad performance if a search returns a large result set, which would then have to be sorted before the first row is returned.

Example

This example shows how to use the CalcFields method to find the balance on December 31, 2008 and the net change for a customer in 2008.

var
    CustomerRec: Record Customer;
begin
    CustomerRec.SetRange("Date Filter",20080101D,20081231D);  
    CustomerRec.CalcFields(Balance, "Net Change");  
end;

The first line sets up a filter for the Date Filter field in the Customer record. This field is a FlowFilter field which is used in the filter definition for several FlowFields in the Customer record. In the second line, the FlowFields are calculated.

Record Data Type
Get Started with AL
Developing Extensions
AL Database Methods and Performance on SQL Server