Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

How to Automatically Insert Line Breaks After 45 Characters in AL Report for Business Central

(2) ShareShare
ReportReport
Posted on by 149

Hello everyone,

I'm working on customizing an AL report (Cheque) in  Business Central. The report includes a field that converts numeric amounts into words (AmountInWords). However, when the converted text exceeds 45 characters, it overflows the designated textbox area on the cheque layout, disrupting the overall layout.

What I Want to Achieve:

  • Automatically insert a line break after 45 characters in the AmountInWords field.
  • Ensure that the text wraps to the next line without manual intervention.
  • Maintain the portrait orientation and alignment consistent with other fields on the cheque
Which function or syntax can help me. I've already try with something like that
local procedure InsertLineBreak(InputText: Text; MaxLength: Integer): Text
var
    FirstPart: Text[255];
    SecondPart: Text[255];
begin
    if STRLEN(InputText) <= MaxLength then
        exit(InputText);
    
    FirstPart := COPYSTR(InputText, 1, MaxLength);
    SecondPart := COPYSTR(InputText, MaxLength + 1, STRLEN(InputText) - MaxLength);
    exit(FirstPart + '\n' + SecondPart); // Tried using '\n', CRLF, and CHAR functions
end;
 
 
How can I solve it?
Thanks in advance!
  • CU07101338-0 Profile Picture
    CU07101338-0 149 on at
    How to Automatically Insert Line Breaks After 45 Characters in AL Report for Business Central
    Thanks for your kind reply;
    Unfortunately nothing happens with this code!
    Is there any alternative solution for that?
    How can we handle long words with too much characters. 
  • Suggested answer
    VaHiX Profile Picture
    VaHiX 3,936 on at
    How to Automatically Insert Line Breaks After 45 Characters in AL Report for Business Central
    May this models can help you:
     
    exit(FirstPart + ENVIRONMENT.NewLine + SecondPart);
    or
    exit(FirstPart + CHAR(10) + SecondPart);

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,885 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,569 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans