+ Start a Discussion

Apex and Documents

I have assembled XML with APEX. Want to write the XML to a file in a documents folder.


But can't find any reference on how to do this.


Any ideas?



Best Answer chosen by Admin (Salesforce Developers) 
Folder f = [SELECT Id FROM Folder WHERE DeveloperName = 'Folder_To_Use'];
// String xmlString;
Document d = new Document(FolderId=f.Id,Body=Blob.valueOf(xmlString),ContentType='text/xml');
insert d;

That's the rough of it.