Hi DEV,
By a way or another, you have to connect on both companies and enter the corresponding documents.
Your choices are DI, DIS and B1if, depending on if it has to be a server process your skills and license used.
But in your sample code, your're connecting only on one of the companies to add a document: not on the second one. You have to open a connection onto the second company and add also the corresponding document.
Regards,
Eric