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:
If I print that in debug log:
Case obj = [SELECT Description FROM Case WHERE Id = '500q0000006XBEP'];
System.debug('description=' + obj.Description);
It gives me:
Update based on comments:
If you just press ENTER button to put in new line like this:
That will give me results:
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;