Skip to Content
author's profile photo Former Member
Former Member

Documents.GetByKey returns an invalid document

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 21, 2004 at 06:37 PM

    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
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      Thank you for your help. This was the suggestion which I also got from the service marketplace today and it finally got me to the root of the problem. As you suggested, I was using the wrong identifier (DocNum instead of DocEntry) for retrieving the document. It worked well on those databases where the default document numbering was used for invoices (starting from 1), but naturally didn't work when a different document numbering scheme was used.

      The thing that was really confusing for me was that the DI API does not throw any exception when I try to call GetByKey with a key that does not point to a document in the database.

      Regards,

      Henry

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.