Problems with Create Relationship of a Document

Hello, I have this module:
Accounts (with a relationship many to many documents_accounts)
AOS_Contracts (with a relationship many to many aos_contracts_documents)
Documents ( with a relationship many to many documents_accounts)

I want that when I create a Document then I see the document in subpanel of Contracts (and this is OK) and also in subpanel of Accounts (I don’t have this)

What I have to do?
Thanks

@riccardomaffei
You can make logichook after_relationship_add for module Documents. Look at documentation here: https://docs.suitecrm.com/developer/logic-hooks/

I have an entrypoint that create a document from php (with bean) but when I create the relationship with this code:

$contract>load_relationship(‘aos_contracts_documents’,$contract->id);
$contract->aos_contracts_documents->add($document);

and relationship don’t load,
then I have create in Studio a new relationship from AOS_Contracts and Documents that has named ‘aos_contracts_documents_1’
for this relation then I create relationship with this code

$contract->load_relationship(‘aos_contracts_documents_1’,$contract->id);
$contract->aos_contracts_documents_1->add($document);

the relationship is OK (the first relationship created by default)

load_relationship only takes one parameter, you don’t need the second one.

So if the second code snippet works, do you still have a problem now? Or is everything solved?

I have solved the problem.
I think that with relationship create in studio you have to “load” relationship in this way

$contract->load_relationship(‘aos_contracts_documents_1’);
$contract->aos_contracts_documents_1->add($document);

with default relationship I have solved with this code

$contract->load_relationship(‘documents’);
$contract->documents->add($document);

Thanks for help

That sounds correct, but I fixed the unnecessary parameter in your first call. It’s not being used and could cause some confusion.