Convert Simple Type Values to Text Using the New ToText Method in Business Central 2025 Wave 1

With the release of Business Central 2025 Wave 1, Business Central continues to simplify AL development by introducing intuitive and developer-friendly features. One such small yet powerful enhancement is the ToText method — designed to streamline how simple type values are converted to text.

In previous versions, we developers often relied on FORMAT() for converting simple types like integers, decimals, booleans, and option values into text. While FORMAT() has been effective, it comes with localization considerations and sometimes produces inconsistent results depending on the environment or the formatting settings.

✨ What’s New: ToText Method

The new ToText method is a type extension method introduced for simple AL types. It provides a clearer, more consistent way to convert values to string representations without the overhead of full formatting logic.

Supported Types

The ToText method supports the following simple types:

  • Integer
  • Decimal
  • Boolean
  • Char
  • Option
  • Date
  • Time
  • DateTime
  • GUID

Let’s look at some examples of how the ToText() method can simplify your code:

var
    myInteger: Integer := 42;
    myDecimal: Decimal := 2.71828;
    myDate: Date := TODAY;
    myTime: Time := TIME(10, 30, 0);
    myBoolean: Boolean := true;
    myOption: Option Alpha,Beta,Gamma := Option::Beta;
    integerAsText: Text;
    decimalAsText: Text;
    dateAsText: Text;
    timeAsText: Text;
    booleanAsText: Text;
    optionAsText: Text;
begin
    integerAsText := myInteger.ToText(); // integerAsText will be '42'
    decimalAsText := myDecimal.ToText(); // decimalAsText will be '2.71828' (or similar based on locale)
    dateAsText := myDate.ToText();       // dateAsText will be the default short date format
    timeAsText := myTime.ToText();       // timeAsText will be the default time format
    booleanAsText := myBoolean.ToText(); // booleanAsText will be 'true'
    optionAsText := myOption.ToText();   // optionAsText will be 'Beta'
    Message('Integer: %1', integerAsText);
    Message('Decimal: %1', decimalAsText);
    Message('Date: %1', dateAsText);
    Message('Time: %1', timeAsText);
    Message('Boolean: %1', booleanAsText);
    Message('Option: %1', optionAsText);
end;

Prefer ToText() when you want predictable results across environments (e.g., when storing values in logs or metadata).

Continue using FORMAT() when you need locale-aware output, such as in printed documents or user-facing formatted messages.

It simplifies the process of converting simple data types to their default text representations, leading to cleaner, more readable, and potentially more efficient code. While FORMAT() remains the go-to for advanced formatting needs, ToText() will undoubtedly become a frequently used tool in your Business Central development.

Stay tuned for more…

AutoFormatExpression Property in Business Central – Wave 1 2025

With the release of Business Central 2025 Wave 1, Microsoft continues enhancing the AL language to make development cleaner, more flexible, and maintainable. One of the updates includes improvements around the AutoFormatExpression property — a property that may seem minor but plays a crucial role in controlling how data is displayed, especially in reports and pages.

In essence, the AutoFormatExpression property allows you to define a specific format for how numeric and date/time values are displayed in your Business Central application. This goes beyond the basic formatting options and provides granular control over aspects like decimal places, thousands separators, date and time patterns, and more.

What is the AutoFormatExpression Property?

The AutoFormatExpression property in AL is used to specify a formatting expression that overrides the default formatting behavior of a control. It works in conjunction with the AutoFormatType property and is typically used in pages and reports to control how numeric or date values are displayed.

For example, you might want to display a date in DD-MM-YYYY format instead of the system default, or format a decimal with specific currency or precision rules.

How Does AutoFormatExpression Work?

The AutoFormatExpression property accepts a string that defines the desired format. The syntax of this string follows specific rules depending on whether you are formatting numeric or date/time data.

For Numeric Data:

The expression can include placeholders for:

  • Decimal Places: Use # for optional digits and 0 for mandatory digits after the decimal point.
  • Thousands Separator: Typically a comma (,), but this can be influenced by regional settings.
  • Currency Symbol: The currency symbol is usually determined by the AutoFormatType and AutoFormatSubType properties.

Example:

  • #,##0.00: Displays numbers with two decimal places and thousands separators (e.g., 1,234.56).
  • 0.0: Displays numbers with one mandatory decimal place (e.g., 123.4).

For Date/Time Data:

The expression uses specific codes to represent different parts of the date and time:

  • Days: d (day of the month), dd (day of the month with leading zero), ddd (abbreviated day name), dddd (full day name).
  • Months: M (month number), MM (month number with leading zero), MMM (abbreviated month name), MMMM (full month name).
  • Years: yy (two-digit year), yyyy (four-digit year).
  • Hours: h (12-hour format), hh (12-hour format with leading zero), H (24-hour format), HH (24-hour format with leading zero).
  • Minutes: m (minutes), mm (minutes with leading zero).
  • Seconds: s (seconds), ss (seconds with leading zero).
  • Milliseconds: f, ff, fff (fractional seconds).
  • AM/PM: tt (AM/PM designator).
  • Time Separator: Typically a colon (:), but this can be influenced by regional settings.
  • Date Separator: Typically a slash (/), hyphen (-), or period (.), but this can be influenced by regional settings.

Examples:

  • MM/dd/yyyy: Displays date as month/day/year (e.g., 12/25/2025).
  • dd-MMM-yy hh:mm tt: Displays date and time with abbreviated month and 12-hour format (e.g., 25-Dec-25 06:36 PM).
  • dddd, MMMM dd, yyyy: Displays the full day, month, and year (e.g., Monday, December 25, 2025).
table AutformatTable
{
    fields
    {
        field(1; "Amount"; Decimal)
        {
            AutoFormatType = 10; // Currency
            AutoFormatExpression = "#,##0.00";
        }
        field(2; "Order Date"; Date)
        {
            AutoFormatExpression = "MM/dd/yyyy";
        }
        field(3; "Order Time"; Time)
        {
            AutoFormatExpression = "hh:mm:ss tt";
        }
    }
}

page AutoFormatPage
{
    layout
    {
        area(content)
        {
            group(GroupName)
            {
                field("Amount"; Rec.Amount)
                {
                    // Inherits AutoFormatExpression from the table field
                }
                field("Formatted Amount"; Rec.Amount)
                {
                    AutoFormatExpression = "0.##"; // Overrides table field format for this instance
                }
                field("Order Date"; Rec."Order Date")
                {
                    // Inherits AutoFormatExpression from the table field
                }
                field("Order Time"; Rec."Order Time")
                {
                    // Inherits AutoFormatExpression from the table field
                }
            }
        }
    }
}

Another example could be as follows

pageextension 50100 CustomerListExt extends "Customer List"
{
    layout
    {
        addlast(content)
        {
            field("Balance LCY"; Rec."Balance (LCY)")
            {
                ApplicationArea = All;
                AutoFormatType = 1;
                AutoFormatExpression = Rec."Currency Code";
            }
        }
    }
}

While AutoFormatExpression gives you precise control, be aware that regional settings can still influence aspects like decimal and thousands separators, as well as date and time formats if not explicitly defined.

The AutoFormatExpression property in Business Central Wave 1 2025 is a significant enhancement for developers looking to control the presentation of numeric and date/time data.

Stay tuned for more !!!

Business Central 2025 Wave 1 (BC26): Check Total Purchase Amounts on Documents

The Business Central 2025 Wave 1 (BC26) release introduces a valuable feature aimed at enhancing the accuracy and efficiency of accounts payable processes: “Check Doc. Total Amounts”. While seemingly simple from a user perspective, but powerful addition that helps users validate purchase documents before posting.

At its heart, “Check Doc. Total Amounts” is designed to prevent posting discrepancies between the manually entered total amounts on purchase document headers and the calculated total amounts based on the individual purchase lines. This helps ensure that the data within Business Central accurately reflects the external vendor invoices, minimizing potential errors and reconciliation issues.

Implementation Details:

Setup: The functionality is controlled via a new option within the Purchases & Payables Setup page. Administrators need to explicitly enable the “Check Doc. Total Amounts” toggle. This opt-in approach ensures that existing environments are not impacted unless the feature is intentionally activated.

New Fields: Upon enabling the feature, two new fields become visible on the Purchase Invoice and Purchase Credit Memo pages:

  • Doc. Amount Incl. VAT: This field is intended for users to enter the total amount, including VAT, as stated on the vendor’s document.
  • Doc. Amount VAT: This field allows users to enter the total VAT amount as per the vendor’s document.

Automatic Calculation: When a user enters a value in the “Doc. Amount Incl. VAT” field, the system automatically calculates and populates the “Doc. Amount VAT” field based on the VAT rates applied to the individual purchase lines. Conversely, if the user enters the “Doc. Amount VAT”, the “Doc. Amount Incl. VAT” is automatically calculated.

Validation on Posting: The crucial technical aspect lies in the posting validation logic. When a user attempts to post a Purchase Invoice or Purchase Credit Memo with the “Check Doc. Total Amounts” feature enabled, Business Central performs the following checks:

  • It calculates the sum of the “Amount Including VAT” for all individual purchase lines.
  • It calculates the total VAT amount based on the VAT entries of the purchase lines.
  • It compares these calculated totals with the values entered in the “Doc. Amount Incl. VAT” and “Doc. Amount VAT” fields on the document header.

Error Handling: If the calculated total amounts from the lines do not match the manually entered amounts on the header, the system will prevent posting and display an error message to the user. This forces a review of the purchase lines and header information to identify and rectify any discrepancies before the document can be posted.

The “Check Doc. Total Amounts” feature in Business Central 2025 Wave 1 (BC26) is a welcome addition for improving the accuracy of purchase document processing.

Stay tuned for more.

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

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.

Embedding Powerful UI with UserControlHost PageType in Business Central

With the release of Business Central 2025 Wave 1, new page type UserControlHost is introduced which enables embedding custom JavaScript-based controls into the Business Central web client.

🔍 What is UserControlHost?

The UserControlHost page type allows you to embed custom client-side controls—typically written in JavaScript—inside the Business Central web client using the ControlAddIn object.These controls are built with web technologies—JavaScript, HTML, and CSS—and provide flexibility far beyond standard AL UI elements.

Think of UserControlHost as a “wrapper” that renders client-side controls defined via the ControlAddIn object.

You might consider using UserControlHost for:

  • Advanced data visualizations (charts, graphs, maps)
  • Dynamic dashboards or interactive UI widgets

🧱 How to use

To use the UserControlHost, you need two key components:

  1. A Control Add-In (ControlAddIn)
  2. A Page with PageType = UserControlHost
  1. Create the ControlAddIn
controladdin "MyWave2025Control"
{
    Scripts = 'scripts/chart.js', 'scripts/mycontrol.js';
    StartupScript = 'scripts/init.js';
    StyleSheets = 'styles/mycontrol.css';

    RequestedHeight = 400;
    RequestedWidth = 600;

    AutoAdjustHeight = true;
    AutoAdjustWidth = true;

    Events = OnItemSelected(text);
    Methods = LoadData(data: Text);
}

2) Create the UserControlHost Page

page 50200 "Dashboard Host"
{
    PageType = UserControlHost;
    ApplicationArea = All;

    layout
    {
        area(content)
        {
            usercontrol(MyCustomChart; "MyWave2025Control")
            {
                ApplicationArea = All;
            }
        }
    }

    trigger OnOpenPage()
    begin
        CurrPage.MyCustomChart.LoadData('{"region": "Thailand"}');
    end;

    trigger OnControlReady()
    begin
        Message('Custom Control is ready!');
    end;
}

The UserControlHost page type, especially with Wave 1 2025 enhancements, is the go-to choice for scenarios where traditional AL UI just won’t cut it. Whether you’re building modern dashboards, embedding custom charts, or creating interactive widgets

Using the New IncStr Overload in Business Central AL

With recent updates to AL language in Microsoft Dynamics 365 Business Central, developers now have more flexibility when working with strings containing numeric suffixes — thanks to the new overload of the IncStr method.

If you’ve ever had to increment a string with a number at the end (e.g., “INV001” to “INV002”), you’ve probably used IncStr. But until recently, IncStr only allowed an increment of +1.

Let’s explore how the new overload changes that.

🆕 What’s New in IncStr?

Traditionally, IncStr was used like this:

NewString := IncStr('INV001');  // Result: 'INV002'

Now, with the new overload, you can specify how much to increment by:

NewString := IncStr('INV001', 5);  // Result: 'INV006'

✅ Syntax:

IncStr(Value: String, IncrementBy: Integer): String

This enhancement is particularly useful in scenarios like:

  • Batch processing: Skipping ranges (e.g., test IDs, invoice numbers)
  • Custom logic: Implementing non-sequential numbering patterns
  • Looping identifiers: Where the next string isn’t always +1

⚙️ Example

LastCode := IncStr(LastCode, 5); // Jump by 5 in one go

🚧 Cases to Consider

  • It only increments the last numeric section of the string.
  • It respects the original number of digits (e.g., padding).
  • If there’s no number, it defaults to 1 and appends it.

IncStr('ABC', 3);  // Result: 'ABC3'

The new IncStr overload is a small change with big impact — making it easier to handle advanced string number incrementing without tedious code.

Stay Tuned for more.

SessionInformation.Callstack() in Business Central

Introduced in Business Central Wave 1 2025 releases, the SessionInformation.Callstack() method is a powerful diagnostic tool that helps developers trace the current call stack within AL code. Whether you’re troubleshooting custom extensions, tracking errors, or building telemetry, this method can become your best friend.

What is the SessionInformation.Callstack() Method?

The SessionInformation.Callstack() method is a built-in function in AL that returns a text string representing the current call stack of the Business Central server session. Think of the call stack as a chronological list of the functions and procedures that have been called to reach the current point in your code.

Each entry in the call stack typically includes:

  • Object Type and Name: The type of object (e.g., Codeunit, Table, Page) and its name.
  • Function/Procedure Name: The specific function or procedure being executed.
  • Line Number: The line number within the function/procedure where the call originated.

📌 Syntax

var
    CallStackText: Text;
begin
    CallStackText := SessionInformation.Callstack();
end;

🧩 Why is the Call Stack Important?

Understanding the call stack is crucial for several reasons:

  • Debugging: When an error occurs, the call stack provides a trace of the execution path leading up to the error. This helps you pinpoint the exact location where the issue originated and understand the sequence of events that triggered it.
  • Error Handling: By capturing and logging the call stack when an error occurs, you can provide more context to administrators or support teams, making it easier to diagnose and resolve issues.
  • Code Understanding: Analyzing the call stack can help you understand the flow of execution in complex codebases, especially when working with unfamiliar code or trying to understand how different modules interact.

You can combine this with

  • ErrorInfo object (for AL error handling)
  • SessionInformation.UserId() or CompanyName() for full diagnostic logs
var
    CallStack: Text;
    ErrorData: ErrorInfo;
begin
    if not TryMyFunction() then begin
        GetLastError(ErrorData);
        LogToTable('Error: %1 - Stack: %2', ErrorData.Message, SessionInformation.Callstack());
    end;

SessionInformation.Callstack() is a small method with big potential. It’s the AL developer’s X-ray — revealing the path of execution in complex customizations or tangled logic.

Use it smartly, especially in:

  • Error handling routines
  • Long-running jobs
  • Telemetry and diagnostics pipelines

Stay Tuned for more updates

Production Order Cancellations: Reversing Consumption in Business Central V26

Production orders are the backbone of manufacturing operations, but sometimes, plans change. Orders need to be cancelled, and when those orders have already consumed materials, things can get tricky. Business Central V26 has stepped in to simplify this process, offering a more streamlined way to reverse consumption and cancel production orders. Let’s explore how this works.

Imagine you’ve started a production order, materials have been consumed, and then, for whatever reason, the order needs to be scrapped. In previous versions of Business Central, simply deleting the order wasn’t an option. The system needed a way to accurately reverse the consumption entries to maintain inventory and financial integrity. This often involved manual adjustments and could be a time-consuming, error-prone process.

Business Central V26: Simplifying the Reversal:

Enter the “Reverse Production Order Transaction” action in Business Central V26. This feature provides a more efficient and accurate way to undo consumption and output transactions, making production order cancellations less of a headache.

How it Works:

  • Reversing Item Ledger Entries:
    • When you use the “Reverse Production Order Transaction” action, Business Central generates reversing item journal lines.
    • These lines effectively negate the original consumption entries, returning the materials to inventory.
  • Handling Output and Capacity:
    • The system also reverses output and capacity entries, including quantities, scrap, setup time, and run time.
    • This ensures that all related ledger entries are accurately adjusted.
  • Accurate Ledger Updates:
    • The system applies these reversals to the original ledger entries, maintaining precise inventory and cost records.

After reversal of production order you can finish production order without output. To achieve this you need to enable the setup on Manufacturing setup

Activate the Finish Order Without Output toggle in the Manufacturing Setup page.

Business Central V26’s enhanced capabilities for reversing production order transactions represent a significant step forward in simplifying production management. By automating the reversal process, manufacturers can save time, reduce errors, and maintain accurate inventory and financial records. This feature is a valuable addition to the Business Central , making production order cancellations less of a burden and more of a seamless operation.

Stay tuned for more updates.

Preview PDFs Directly in Business Central Web Client (v26)

With the release of version 26, a significant productivity boost has arrived: direct PDF attachment previews within the web client. No more downloading, opening external viewers, or switching between applications. This streamlined experience lets you access and review crucial documents instantly, right within your Business Central workflow.

What Does This Mean For You?

Imagine you’re processing a purchase order and need to quickly verify the attached vendor invoice. Previously, you’d have to download the PDF, open it in a separate application, and then return to Business Central. This process was time-consuming and disruptive.

Now, with the new preview functionality, you can:

  • View PDFs directly in the FactBox: When a PDF is attached to a record (like a sales order, purchase invoice, or customer card), you can preview it instantly in the FactBox without leaving the page.
  • Save time and improve efficiency: Eliminate the need for downloads and external viewers, allowing you to focus on your core tasks.
  • Enhance collaboration: Quickly share and review documents with colleagues, streamlining approvals and decision-making.
  • Enjoy a seamless user experience: The integrated preview functionality provides a more intuitive and efficient workflow.

How Does It Work?

The new feature leverages the browser’s built-in PDF rendering capabilities. When you click on a PDF attachment in the FactBox, the document opens directly within the Business Central web client, allowing you to:

  • Scroll through pages.
  • Zoom in and out.
  • Search for specific text.

This feature is enabled by default in Business Central version 26. Simply open a record with a PDF attachment, and you’ll see the preview option in the FactBox.

For Developers:

  • Microsoft has added the following AL methods to enable this functionality.
    • File.ViewFromStream (for Business Central online)
    • File.View (for Business Central on-premises)

Reopening Finished Production Orders in Business Central v26 (Wave 1 2025)

Microsoft Business Central is constantly evolving, bringing us new features and enhancements with each wave release. One highly anticipated addition in Wave 1 2025 (v26) is the ability to reopen finished production orders. This seemingly simple functionality addresses a long-standing pain point for many manufacturers, offering increased flexibility and control over their production processes.

The Challenge

Previously, once a production order was marked as “Finished,” it was essentially locked. Any necessary adjustments, corrections, or further processing required creating a new production order, leading to potential data discrepancies and cumbersome workarounds. This rigid approach often hindered efficient handling of rework, returns, or unexpected post-production requirements.

The Solution: Reopening Finished Orders

With the v26 update, Business Central introduces the capability to reopen finished production orders.

To reopen a production order, follow these steps:

  1. On the Finished Production Orders page, select the order you want to edit.
  2. Choose the Reopen action.
  3. In the Do you want to reopen the production order? confirmation dialog, choose Yes.

This empowers users to:

  • Correct Errors: If errors are discovered after finishing an order (e.g., incorrect quantity reporting, wrong item consumption), you can reopen the order, make the necessary adjustments, and re-finish it.
  • Handle Rework or Returns: If products need rework or are returned, you can reopen the finished order, register the required adjustments, and complete the rework process within the original order.
  • Add Post-Production Activities: If additional operations or processes are needed after the order is finished (e.g., special packaging, additional quality checks), you can reopen the order and register these activities.
  • Maintain Data Integrity: Reopening the original order ensures a consistent and accurate audit trail, preventing data fragmentation and improving reporting accuracy.

As we approach the release of Wave 1 2025, stay tuned for more detailed information and practical examples on how to leverage this valuable feature.