CalcFields is a method to calculate the FlowFields in a record.
Flowfields are special fields (virtual) that are not stored physically in the database/table. Standard fields are loaded once the record is retrieved from the database. However, as the flowfields are virtual and show data (or grouped data) from another table, calculating these fields means to query another table with another SQL statement. As this can (and usually is) very performance-intensive task, FlowFields are not automatically calculated when the record is loaded from the database.
For fields shown on pages, values are automatically loaded (as if the field is shown on the page, it is usually intended to show the value of the field. However, if a developer works with FlowField in AL or C/AL language and needs to work with its value, the value must be calculated manually first (using CalcFields method).
See example below
SalesHeader.SetRange("Document Type", SalesHeader."Document Type"::Order); SalesHeader.SetRange("Date Filter", 010119D, 123119D); if SalesHeader.FindSet() then repeat // Nothing is shown as the FlowField is not calculated // Shown message: "Order XYZ: 0" Message('Order %1: %2', SalesHeader."No.", SalesHeader.Amount); // Calculate Amount field using CalcFields method SalesHeader.CalcFields(Amount); // Now the message show right Amount of each Sales Order // Shown message: "Order XYZ: 123 665.23" Message('Order %1: %2', SalesHeader."No.", SalesHeader.Amount); until SalesHeader.Next() < 1;