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
InstallfreeInstallfree 

How to copy text from an exisitng long text area field to a new rich text area field

Hi,

I have copied text from an exisitng long text area field to a new rich text area field successfully using the following apex method (Encapsulation_NewInstructions__c is a rich text area field):

 

WebService static void UpdateEncapsSteps()

{

List <Solution> solutions = new List<Solution>();

for (Solution mySol : [Select Id, Encapsulation_Instructions__c, Encapsulation_NewInstructions__c From Solution])

{

mySol.Encapsulation_NewInstructions__c = mySol.Encapsulation_Instructions__c;

solutions.add(mySol);

}

update solutions;

}

 

All went well except text have been copied without the break lines (I suppose that in long text area break line is '/r/n' and the new rich text area field doesn't know to convert it into an HTML structure).

 

for example:

 

The origin was:

"straight forward. Need to run the Encapsulator from a short path (For example E:\43a and not C:\documents and settings\user\desktop\encapsulator 1.0.0.43a').
Otherwise, the encapsulation fails." 

 

The result was:

straight forward. Need to run the Encapsulator from a short path (For example E:\43a and not C:\documents and settings\user\desktop\encapsulator 1.0.0.43a'). Otherwise, the encapsulation fails.

 

How can I convert text to HTML format and saving the structure?

Do I have build in method for this?

 

Thanks

Shuky

 

akschampakschamp

I am facing same problem....can anyone look into this...please?

nateienateie

+1

 

I can't seem to access a Long Text Area from my formula field.

 

Error: You referenced an unsupported field type called "Long Text Area" using the following field: Description

samrat.1985@lntinfotechsamrat.1985@lntinfotech

I am facing the same problem.

Please anyone answer. I know its not supported but is there any work around to include it in the Formula field.

 

You referenced an unsupported field type called "Rich Text Area" using the following field: Rich__c

IlseIlse

Exactly the same issue here! Can someone please give a workaround or solution

IlseIlse

The solution is to use the following code to replaces linebreaks in text and replace them with <br/>

 

public string getCaseDescriptionFormatted()

{

    Case c = this.loadCaseFromDatabaseOrWhatever();

    return lineBreaks(c.Description);  

}

 

private string lineBreaks(string inText)

{

   if (inText == null)

       return '';

   else

       return inText.replaceAll('<','(').replaceAll('>',')').replaceAll('\n','<br/>');

}