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?
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?
If I understand correctly you have a module, let's say A, which is related to Documents, and you want to retrieve the Documents related to A programmatically.
This can be achieved via the API:
GET /<module>/:record/link/:link_name
In our example <module> is A, :record is the id of the record in A that you are looking at, and :link_name is the name of the relationship between A and Documents.
For help finding the link_name see:
Hope this helps,
FrancescaS
I guess I wasn't able to elaborate it properly.
We have two modules a- Notes and b- Documents.
There is one field named file_attachment in notes module.
Let's suppose I uploaded a file (A) in notes module
Now what I want is that I want to show that file (A) in documents module as well.
I hope I am able to elaborate it now.
And thanks for your time.
I think you will have to duplicate the file. Each module, Notes and Documents, will need to have its own ID and files are stored by ID in the file system.
Perhaps someone else will have a better solution for you, sorry I could not be helpful.
FrancescaS
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' )");