How to generate a file and store it under Document using Apex in Salesforce?

Sample Code:          

            Document d = new Document();       
            d.FolderId = '00l90000001KHtg';    //Id of the folder under Documents
            d.Name = e.Name + Date.Today();       
            d.ContentType = 'text/plain';       
            d.Body = Blob.valueOf(e.Name + ' ' + e.State__c);               
            
             insert d;

Cheers!!!

No comments:

Post a Comment