0

I'm not sure if this is even possible in a standard page layout, I have Long Text Area(32768) on a custom field Message__c so the data I have is with line break as shown below and I have tried \n but I'm getting everything in one line.

I'm trying to achieve something like this:

This is a line one 
this is a line two 
this is a line three 
Last line

enter image description here

1

Not sure I have understood your question correctly.

I am updating Case Description field (which is LongTextArea(32000)) from Developer console like this:

Case obj = [SELECT Description FROM Case WHERE Id = '500q0000006XBEP'];
obj.Description = 'First Line' + '\n\r' + 'Second Line' + '\n\r' + 'Third Line';
update obj;

And it is showing in UI:

Case description

If I print that in debug log:

Case obj = [SELECT Description FROM Case WHERE Id = '500q0000006XBEP'];
System.debug('description=' + obj.Description);

It gives me:

case desc debug

Update based on comments:

If you just press ENTER button to put in new line like this:

case desc1

That will give me results:

case desc 2

2nd Update from Comments:

if you are receiving text like this

This is a line one <br> this is a line two <br> this is a line three <br>Last line

Then just replace <br> with \n\r before assigning that into the field and it will work.

Case obj = [SELECT Description FROM Case WHERE Id = '500q0000006XBEP'];
String str = 'This is a line one <br> this is a line two <br> this is a line three <br>Last line';
obj.Description = str.replace('<br>','\n\r');
update obj;
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.