InfoPath – Add line break in text field

Sometimes you get a request that someone wants to add automatically line breaks into a textfield. In this case the user wants to input any date and the all previous and in future typed in information should be listed in a textfield as history.

In order to get this working you have to insert two fields.

Any field “input” and text field “history”.
The history field has to be a normal textfield not a multiline field. This won’t work. So you have the limitation of 256 letters of course. But it should work for enough data normally.

Now you have to create a xml-file like this:

<?xml version=”1.0″ encoding=”UTF-8″?>
<characters
cr=”&#xD;”
lf=”&#xA;”
crlf=”&#xD;&#xA;”
/>

After that you can add this xml file as resource file via data connections.

Then you only need to create a rule on input field.

if field value changes (no conditions) the set the field history to the following function:

concat(input, crlf, history)

The CRLF is a field from the xml document (as secondary data source) and it creates a line break. Sometimes you have to your LF Value to get it working.

The important thing is that the textfield is a normal textfield. In Infopath you change the size of the textfield and in the properties you should make it multiline ready.

In the SharePoint list it also display the values of history with line breaks.


Some more infos are available here: https://blogs.msdn.microsoft.com/infopath/2005/03/04/inserting-line-breaks-into-text-using-rules/

The article or information provided here represents completely my own personal view & thought. It is recommended to test the content or scripts of the site in the lab, before making use in the production environment & use it completely at your own risk. The articles, scripts, suggestions or tricks published on the site are provided AS-IS with no warranties or guarantees and confers no rights.

About Karsten Schneider 312 Articles
Consultant for Microsoft 365 Applications with a strong focus in Teams, SharePoint Online, OneDrive for Business as well as PowerPlatform with PowerApps, Flow and PowerBI. I provide Workshops for Governance & Security in Office 365 and Development of Solutions in the area of Collaboration and Teamwork based on Microsoft 365 and Azure Cloud Solutions. In his free time he tries to collect tipps and worthy experience in this blog.

Be the first to comment

Leave a Reply

Your email address will not be published.


*