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

Copy Document to Notes and Attachments on Objects Using Document Id

I have a custom object that represents a document, and contains the document Id. I'd like to use that document Id and add that document to the notes and attachments section of that object. Any help in the right direction would be appreciated.
So the document is a real salesforce document?  IE - you can get it from the Document tab?  If that's so  - I think you can do code something like this...
Document d = [select id, body from document where id = :idThatYouveGot];

Attachment a = new Attachment(Name='New Attachment Name',
  body = d.body,
  parendId =;

insert a;

document.body is a blob, so you might have to do something like
blob dblob = d.body;

then assign that dblob to the attachment.body.

Not sure that might give you somewhere to start.