Skip to main content

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

Hi,

Introduction

Microsoft has introduced a new ToText method in Business Central 2025, making it easier to convert simple type values to text. This update simplifies data conversion, reducing the need for complex formatting functions like FORMAT in scenarios where basic type conversion is sufficient.

In this blog, we will explore the ToText method, supported data types, benefits, and use cases in Business Central AL development.

Business Value

Before this feature, developers relied on FORMAT to convert different types into text. While FORMAT provides advanced formatting capabilities, it can be overkill for simple conversions. The ToText method allows developers to convert values directly on the type, making the process more intuitive and efficient.

Feature Details

The ToText method is now available on the following simple types:

  • BigInteger

  • Boolean

  • Byte

  • Date

  • DateTime

  • Decimal

  • Duration

  • Guid

  • Integer

  • Label

  • Time

  • Version

This method provides a cleaner alternative to FORMAT when complex formatting is unnecessary. It enhances code readability and improves performance by avoiding unnecessary formatting logic.

How To Use the ToText Method

Example 1: Convert an Integer to Text

var
    MyInt: Integer;
    MyText: Text;
begin
    MyInt := 100;
    MyText := MyInt.ToText();
    Message(MyText); // Output: "100"
end;

Example 2: Convert a Boolean to Text

var
    IsActive: Boolean;
    StatusText: Text;
begin
    IsActive := true;
    StatusText := IsActive.ToText();
    Message(StatusText); // Output: "true"
end;

Example 3: Convert a Date to Text

var
    MyDate: Date;
    DateText: Text;
begin
    MyDate := Today;
    DateText := MyDate.ToText();
    Message(DateText); // Output: "2025-03-20" (Format may vary based on region)
end;


Benefits of Using ToText

Simplifies Code – No need to call FORMAT for simple type conversions. 

Improves Performance – Reduces overhead from complex formatting. 

Increases Readability – Developers can directly call .ToText() on variables. 

Avoids Unnecessary Formatting – Prevents formatting errors caused by locale settings.

Use Cases in Business Central Development

  • Displaying dynamic values in pages or reports without extra formatting.

  • Logging and debugging, where you need to quickly convert types to text.

  • Data exports where simple type conversion is required.

Availability

The ToText method is available in Business Central 2025 (April 2025) for all users, including admins, makers, and developers.

Conclusion

The ToText method is a welcome addition to Business Central, allowing developers to write cleaner and more efficient AL code. If you are working with Business Central 2025 Wave 1, be sure to try out this new feature and streamline your type conversions!

💡 What are your thoughts on this new feature? Let us know in the comments below or on our social media channels!

📌 Subscribe for more Business Central updates and tutorials! 🚀
https://youtube.com/c/sauravdhyani

#BusinessCentral #ALDevelopment #MicrosoftAL #D365BC #BusinessCentral2025 #MicrosoftDynamics

 Regards,
 Saurav Dhyani

Comments

Popular posts from this blog

RTC Report It is not possible to instantiate the Visual Studio bridge.

Hi all, As a Navision developers I have Multiple Versions of Navision running in single Machine. As discussed Earlier in the post how to run multiple Version of RTC in single machine. So my machine have following details for RTC Versions - NAV 2009 R2    - is installed. NAV 2009 SP1  - is copied at C:\Program Files (x86)\Microsoft Dynamics NAV\60\NAV 6.0 SP1 IN\ NAV 2009         - is copied at C:\Program Files (x86)\Microsoft Dynamics NAV\60\NAV 6.0 IN\ This approach has been working great for execution of Classic and RTC Clients. However, after installing Dynamics NAV 2009 R2, if i tried to view the Layout for an NAV 2009 SP1 Report i was getting the following error: ---------------------------  Microsoft Dynamics NAV Classic  ---------------------------  It is not possible to instantiate  the Visual Studio bridge.  ---------------------------  OK    --------------------------- After searchi...

Dynamics NAV - All that you need to know about MenuSuites.

Hi Readers, This article is based on a request from a blog reader who wanted to understand about MenuSuite in Dynamics NAV. If you have started working with Business central with AL Code then it does not apply to those releases but if you are interested go ahead. Let's start with Future - In Latest and greatest version of product MenuSuite are obsolete and no longer used. So this article applies if you want to learn about C/AL MenuSuite.

NAV 2013 R2 - Cumulative update 12 Released.

Hi all, Please find below the details of  Cumulative Update 12 released for Microsoft Dynamics NAV 2013 R2. Title - Cumulative Update 12 for Microsoft Dynamics NAV 2013 R2 Build No. - 38053 Release Date - October, 2014 Local Version Included - AU, AT, BE, CH, DE, DK, ES, FI, FR, IS, IT, NA, NL, NO, NZ, SE, UK, RU Download Link Note: Implementing this cumulative update will require a database conversion unless you have already implemented update rollup 5.