function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Devendra@SFDCDevendra@SFDC 

How to add new line in string?

Hello Folks,

 

I am using a string to concatenate address fields. Say Address1__c, Address__C, Address__c. When I concatenate these fields it becomes a longer string.

 

Hence I want to add a new line character into the string, so that when it displays on the page - address 1, address 2 and address 3 would appear on the new line.

 

How can we achive this? I was trying with adding a '\n' character into the string. But it wasn't working.

 

Thanks,
Devendra S

 

 

 

 

 

 

 

Neha LundNeha Lund

Hi,

 

In Internet explorer, it is '\r\n'

 

 

Sfd developerSfd developer

Hi,

 

Add <br> at the end of each string 

 

Address1__c,\r\n Address__C,\r\nAddress__c

 

 

Bhawani SharmaBhawani Sharma
\r\n Sir
Yves Asselin 3Yves Asselin 3
Actually, thanks to my co-worker Denis Roy, I was able to find the solution I believe everyone is looking for! First, in your attribute string, add this to where you want your break   &lt;br/&gt;   and then when your reference it, wrap it with aura:unescapedHtml.

Example:

At the top, add this attribute:
<aura:attribute name="title" type="String" default="Connect, talk shop and swap success stories,&lt;br/&gt; pics and trade secrets with members of the community."/>


In your code, add this to your attribute reference like so: 
<aura:unescapedHtml value="{!v.title}" />