Notes attachment in documents module

Good Morning. I'm trying to display the notes attachment in documents module through programmatically. But I don't know how to start the task. Will it be done through API? 

Francesca Shiekh

Parents Reply
  • You can easily copy the note with attachment as document record.

    In below example (after_save logichooks of Notes) I copying the note record as document record with attachment and linking the document record with opportunity.

    $new_document = new Document();
    $new_document->name = $bean->name;
    $new_document->description = $bean->description;
    $new_document->assigned_user_id = $bean->assigned_user_id;
    $new_document->document_name = $bean->name;
    $new_document->status_id = "Active";
    $new_document->document_revision_id = $bean->id;
    $new_document->save();

    $file_ext = substr($bean->filename, strpos($bean->filename, ".") + 1);


    $db->query("INSERT INTO document_revisions (id, change_log, document_id, date_entered, created_by, filename, file_ext, file_mime_type, revision, deleted, date_modified)
    VALUES ('$bean->id', 'Document Created', '$new_document->id', now(), '$bean->assigned_user_id', '$bean->filename', '$file_ext', '$bean->file_mime_type', '1', '0', now() )");
    $do_id = create_guid();
    $db->query("INSERT INTO documents_opportunities (id, date_modified, deleted, document_id, opportunity_id)
    VALUES ('$do_id', now(), '0', '$new_document->id', '$opportunity_id' )");

Children
No Data