Hi Edward,
Access to the event you mentioned requires a UI API connection. Placing a connection on the event is a bad idea (you'll be connection everytime the event is triggered, soon you'll run out of memory).
Assuming you already have the UI API connection you can pull the company object from that connection:
try
{
var gui = new SboGuiApi();
gui.Connect(connectionString);
application = gui.GetApplication();
company = new Company { Application = application };
company.Connect();
}
catch (COMException e)
{
throw ConnectionException.CreateFrom(e);
}
Best practice to establish connection to SAP Business One is at the addon startup. Should be the very first thing you do. Store the reference to your company and application objects (perhaps in a globally accessible place) and you should be fine.
Good luck.
Best regards,
Pedro Magueija
