Business Central 2025 Wave 1 (BC26) – SetAutoCalcFields Method on RecordRef

Amol SalviBusiness Central2 days ago43 Views

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/

0 Votes: 0 Upvotes, 0 Downvotes (0 Points)

Leave a reply

Join Us
  • X Network2.1K
  • LinkedIn3.8k
  • Bluesky0.5K
Support The Site
Events
April 2025
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30     
« Mar   May »
Follow
Sign In/Sign Up Sidebar Search
Popular Now
Loading

Signing-in 3 seconds...

Signing-up 3 seconds...