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
anukarthi_nimmalaanukarthi_nimmala 

Regarding converting rich text editor attribute value to file

Hi,

 

I have a Rich Text Editor value inmy visualforce page(where rich text editor is a  compoonent in my salesforce ).Now i want to pass that value to the controller and convert it to file (.txt/.doc/.csv).I want to convert it to a file type so that i can insert that file to document.body in document object.So please tell me how to convert the component richtext editor value to file type in apex controller.please help me with an example..

my richtext editor component in visualforce page is as below..

 

 

<c:RichEditor value="{!document.description}"         />

 

 

 

 

 

 

 

 

Pradeep_NavatarPradeep_Navatar

You can use the following code :

 

In apex :                

Employee__c emp = [select id ,testrich__c from employee__c where id='a0C90000000QRGm'];

system.debug('+++++++++++++++'+emp.testrich__c);

document d = new document();

d.name='test';

d.body=blob.valueof(emp.testrich__c);

d.contentType =  'image/text';        

d.type= ‘.text’;

d.folderid = UserInfo.getUserId();

insert d;     

 

you can extract the File type(Field: File Extension ) from content type field of document.             

 

Hope this helps.