2025 Mar 18 6:54 AM - edited 2025 Mar 18 6:56 AM
I'm trying to create an Add-On with C# for SAP Business One.
I've known that if the Add-On executed without SAP Application opening, I need to manually set company information to connect to the database.
But if SAP Application is opening, I've known that we can use the connection from UI API and set it to DI API.
I've known 2 methods of it but not sure which method to be used and why it's more efficient.
Method 1
SAPbobsCOM.Company oCompany = new SAPbobsCOM.Company();
string cookie = oCompany.GetContextCookie();
string connectionContext = oApp.Company.GetConnectionContext(cookie);
oCompany.SetSboLoginContext(connectionContext);
oCompany.Connect();
Method 2
SAPbobsCOM.Company oCompany = (SAPbobsCOM.Company)oApp.Company.GetDICompany();
I've found that Method 2 is easier but not sure if there is any limitations or cautions on it.
Please enlighten me. Thanks in advance.
Request clarification before answering.
Hello,
Check the below thread, it have a long discussion about this topic:
Best regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 36 | |
| 26 | |
| 20 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.