+ Start a Discussion
vanessa veronvanessa veron 

delete Document SF


Hi...

how do I delete a document from SF in Apex code?
I created the document in Method 1 and I want to delete it in method 2.
Document mydoc = new Document();
     mydoc.Name =nomFic;
     mydoc.Type = 'csv';
     mydoc.folderid = UserInfo.getUserId(); 
     mydoc.Body = csvBlob;
     insert mydoc;
     delete DOC_CREATED_PREVIOUS;

Ankit AroraAnkit Arora
I just tried this in my org and it worked
Document mydoc = new Document();
mydoc.Name = 'MyDoc2' ;
mydoc.Type = 'csv';
mydoc.folderid = UserInfo.getUserId();
mydoc.Body = null;
insert mydoc;
delete mydoc;

Are you facing any problem deleting document?
vanessa veronvanessa veron
Thank you, but it didn't solve my problem:

I created the document in Method 1 and I want to delete it in method 2.