Dynamic 365 Business central: How to Automatically Insert Line Breaks After a Specific Character Limit
.png)
Suppose, you may have a requirement to break long text into multiple lines after a certain number of characters in Business Central. For example, when dealing with lengthy descriptions in fields like "Work Description," it's important to ensure the text wraps properly to maintain readability. In this scenario, I have implemented a solution using a tableextension to automatically insert line breaks after a specified character length (45 characters in this case). The code takes the input string, breaks it into lines, and formats it accordingly before writing it back to the "Work Description" field. This ensures that the text is displayed in a neat and user-friendly manner in the system. Code: tableextension 50140 MyExtension extends "Sales Header" { trigger OnInsert() var TypeHelper: Codeunit "Type Helper"; Crlf: Text[2]; InputString: Text[2048]; ...