I have come across a really weird DI API problem, which seems to be related to some databases, but not specifically to any specific version of SBO or DI API. I have reproduced the problem on both SBO 6.5 and 2004.
With some databases, especially the demo databases that come along with the SBO installation package, the invoice document that is retrieved with the GetByKey method, does not contain the actual data from the invoice in question. Instead, it seems like it's totally empty. With other databases, the same code works perfectly fine.
Here is the C# code snippet:
============================
doc=(Documents)app.session.GetBusinessObject(BoObjectTypes.oInvoices);
AppData.getInstance().logDebug("Instantiating document no:"+docNo);
doc.GetByKey(docNo);
AppData.getInstance().logDebug("DocTotal from DI API:"+doc.DocTotal);
AppData.getInstance().logDebug("CARDNAME from DI API:"+doc.CardName);
This is what is shown in the log:
=================================
DEBUG - Instantiating document no:105
DEBUG - DocTotal from DI API:0
DEBUG - CARDNAME from DI API:
This is what is shown in the log when using another database:
================================
DEBUG - Instantiating document no:28
DEBUG - DocTotal from DI API:2963,62
DEBUG - CARDNAME from DI API:Inex Partners Oy
...as you can see, the application works well with another database but does not work with another. Both databases are on the same server and are the same version level. In both cases, the document that is being instantiated is of type "oInvoices" and its status is open.
First I thought that this is somehow just related to the demo databases, but now I've come across a customer that is experiencing the same problem. Has anyone seen this kind of problem before?
Regards,
Henry
Henry,
The DocNum you are providing is not the key to load a document by. The DocEntry is.
Each document table contains a DocNum field, as well as a DocEntry field.
You need to load the document by specifying the DocEntry, not the DocNum.
Get the DocEntry from the DocNum using SQL like this:
SELECT * FROM OABC WHERE DocNum = 123456
Add a comment