+ Start a Discussion
GunnarGunnar 

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?

 

Thx.

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox
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.