Business Central 2025 wave 1 (BC26): AL has support for multiline string literals (Multiline strings)

Dynamics 365 Business Central

Hi, Readers.
The public preview for Dynamics 365 Business Central 2025 release wave 1 (BC26) is available. Learn more: Link.

I will continue to test and share some new features that I hope will be helpful

This new feature is not yet documented in the Business Central 2025 release wave 1 (BC26) release plan but is mentioned in AL Language extension changelog Version 15.0

Multiline strings
AL now has support for multiline string literals. A multiline string must be prefixed with @.

https://marketplace.visualstudio.com/items/ms-dynamics-smb.al/changelog

Let’s look at this simple example.

This will be displayed directly on the UI as multiple lines.👏👏👏

Let’s look at another simple example.
We have discussed Dynamics 365 Business Central: How to set multi-line text for a Blob Data Type field via AL before. We used two methods to achieve this.
1. Using CRLF (Carriage Return / Line Feed)

2. Using TextBuilder Data Type
PS: Using TextBuilder Data Type to export data to a text file

With this wave (BC26), we have a third method. Just enter multiple lines directly.

Great.

Source code:

tableextension 50111 MyExtension extends "Sales Header"
{
    trigger OnInsert()
    var
        String: Text[2048];
        OutS: OutStream;
    begin
        String := @'This is line 1
This is line 2
This is line 3';
        Clear("Work Description");
        "Work Description".CreateOutStream(OutS, TextEncoding::UTF8);
        OutS.WriteText(String);
    end;
}

PS: Note that there will be spaces if you align the second line with the code. For example,

And in BC25 and previous versions:
If AL language is not upgraded to 15.0 or above

Expression expected AL AL0224
Text literal was not properly terminated. Use the character ‘ to terminate the literal. AL AL0360

If AL language has been upgraded to 15.0 or above

‘Multiline string literals’ is not available in runtime version ‘14.3’. The supported runtime versions are: ‘15.0’ or greater. AL AL0666

Great. Give it a try!!!😁

Work with multiline strings in AL

Business value:
When developing AL, very long strings are sometimes used. Previously these had to be written in one line, making it hard to easily read content. In this release, we’ve added support for writing out strings spanning multiple lines, allowing developers to format the string content in a more human readable form. This especially helps when working with more structured string content, like JSON content.

Feature details:
You can now write a string in AL that spans multiple lines by prefixing it with @. This allows you to write the string in a more human readable form—for example, when the content is a structured format like JSON content

When using this option, remember that any added white space (such as trying to indent lines) will become part of the string, and is therefore not recommended.

https://learn.microsoft.com/en-us/dynamics365/release-plan/2025wave1/smb/dynamics365-business-central/work-multiline-strings-al?wt.mc_id=DX-MVP-5004336

END

Hope this will help.

Thanks for reading.

ZHU

コメント

Copied title and URL