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.
Convert simple type values to text using new ToText method:
Business value:
https://learn.microsoft.com/en-us/dynamics365/release-plan/2025wave1/smb/dynamics365-business-central/convert-simple-type-values-text-using-new-totext-method?wt.mc_id=DX-MVP-5004336
To easily convert the value of simple types to text, you can now use the ToText method on the type—for example, on a Label type.
This is also mentioned in AL Language extension changelog Version 15.0:
BCIdea Added ToText method to simple types (BigInteger, Boolean, Byte, Date, DateTime, Decimal, Duration, Guid, Integer, Label, Time, Version) for simple conversion to text. Continue to use FORMAT for advanced formatting options.
https://marketplace.visualstudio.com/items/ms-dynamics-smb.al/changelog

The Text Data type denotes a text string. In many standard methods, we need to convert the type to Text before using it, such as Dialog.Message(Text [, Any,…]) Method.
Argument 1: cannot convert from ‘Date’ to ‘Text’ AL AL0133

Generally, we can simply use System.Format(Any, Integer, Text) Method to do this. For example,


With this wave (BC26), we have an easier way. Microsoft has added the ToText method to simple types (BigInteger, Boolean, Byte, Date, DateTime, Decimal, Duration, Guid, Integer, Label, Time, Version) for easy conversion to text.
procedure ToText([Invariant: Boolean]): Converts the value to a text. Equvilant to calling Format(value, 0, 0).
ToText() is the same as format(value)
ToText(true) is the same as format(value,0,9)

All available types are as follows:




Byte:


Date:








Guid:




Label: Although Microsoft mentioned the Label Data type, there is no such method.

However, Label could be directly treated as Text and output directly.


Update info from S-Balslev:

Time:




Small update, but it makes life easier. Give it a try!!!😁
PS: For advanced formatting options, you should continue to use System.Format(Any, Integer, Text) Method.
END
Hope this will help.
Thanks for reading.
ZHU
コメント