Microsoft Dynamics 365 Business Central 2025 Wave 1 (version 26) introduces several enhancements to developer productivity and platform capabilities. One of the notable changes for AL developers is the new SetAutoCalcFields
method added to the RecordRef
data type.
This method brings the power of calculated flow fields to the RecordRef
context, which previously lacked a built-in way to pre-calculate flow fields without manually invoking CALCFIELDS
. Let’s explore what this update means, how it works, and how to use it effectively.
What is
SetAutoCalcFields
?
The SetAutoCalcFields
method allows developers to specify which flow fields (calculated fields) should be automatically calculated when retrieving a record using the RecordRef
data type.
This mimics the behavior of the SetAutoCalcFields
method already available on the Record
data type, extending it to scenarios where developers work with dynamic tables using RecordRef
.
Syntax:
RecordRef.SetAutoCalcFields(Field1, Field2, ...)
Example
procedure DemoSetAutoCalcFields()
var
RecRef: RecordRef;
FieldRef: FieldRef;
FieldRefAmount: FieldRef;
begin
// Open the "Customer" table dynamically
RecRef.Open(Database::Customer);
// Get reference to the "Balance" flow field (Field No. = 21 in Customer)
FieldRefAmount := RecRef.Field(21);
// Set the flow field to auto-calculate
RecRef.SetAutoCalcFields(FieldRefAmount);
// Find a record
if RecRef.FindFirst() then begin
// Now the "Balance" field will be auto-calculated
Message('Customer Balance: %1', FieldRefAmount.Value);
end;
RecRef.Close();
end;
The introduction of the SetAutoCalcFields
method on the RecordRef
data type in Business Central 2025 Wave 1 is a welcome enhancement for developers. It provides a more efficient and streamlined way to work with AutoCalcFields
when using RecordRef
, leading to improved application performance and cleaner, more maintainable code.
Stay tuned for more.
Original Post https://ammolhsaallvi.blog/2025/04/16/business-central-2025-wave-1-bc26-setautocalcfields-method-on-recordref/