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.

Karsten Pohnke About Karsten Pohnke
He is Consultant for SharePoint Solutions for collaboration, communication and business processes. He provides his customers applications based on standard features as well as development or combining the power of several microsoft tools like Dynamics CRM. In his free time he tries to collect tipps and worthy experience in this blog.

Submit comment

Allowed HTML tags: <a href="http://google.com">google</a> <strong>bold</strong> <em>emphasized</em> <code>code</code> <blockquote>
quote
</blockquote>

Please fill in the captcha: * Time limit is exhausted. Please reload CAPTCHA.