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
Jamz_2010Jamz_2010 

TextArea NewLine Character

Hi all,

 

I am just creating a new Note within an Apex method, does anyone know how I can add a new line to the text? I have tried all the standard escape characters but none of them seem to work...

 

Cheers

 

James

Best Answer chosen by Admin (Salesforce Developers) 
Ispita_NavatarIspita_Navatar

Please try this:-

Controller:

public String getStr() {
return 'Test message before
LineFeed';
}

Documentation on linefeed states:-
A Boolean value that specifies whether sensitive HTML and XML characters should be escaped in the HTML output generated by this component. If you do not specify escape="false", the character escape sequence displays as written. Be aware that setting this value to "false" may be a security risk because it allows arbitrary content, including JavaScript, that could be used in a malicious manner.

 

 

 Also the following worked for me:-

 

trigger helloWorldAccountTrigger on Account (before insert) {
Account[] accs = Trigger.new;
trigger.new[0].nav_isp__Competition__c='ooo---\n====='; 
//in this nav_isp__Competition__c is a Textarea field and I got  the following output    ooo---

//                                                                                                                                                         ======
 MyHelloWorld.addHelloWorld(accs);
}

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.

All Answers

Ispita_NavatarIspita_Navatar

Please try this:-

Controller:

public String getStr() {
return 'Test message before
LineFeed';
}

Documentation on linefeed states:-
A Boolean value that specifies whether sensitive HTML and XML characters should be escaped in the HTML output generated by this component. If you do not specify escape="false", the character escape sequence displays as written. Be aware that setting this value to "false" may be a security risk because it allows arbitrary content, including JavaScript, that could be used in a malicious manner.

 

 

 Also the following worked for me:-

 

trigger helloWorldAccountTrigger on Account (before insert) {
Account[] accs = Trigger.new;
trigger.new[0].nav_isp__Competition__c='ooo---\n====='; 
//in this nav_isp__Competition__c is a Textarea field and I got  the following output    ooo---

//                                                                                                                                                         ======
 MyHelloWorld.addHelloWorld(accs);
}

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.

This was selected as the best answer
Jamz_2010Jamz_2010

Cheers for that, I was sure I had tried using \n before and it didn't work (infact I'm sure I tried \r too!). Oh well, \n seems to be working for me now...

 

Thanks again

 

James