Skip to Content

Service Layer Invoices

When using the Service layer, i need to create an invoice from a delivery, but placed within the line 0 sends me the error, but the other lines work fine:

"{

"error" : {

"code" : -10,

"message" : {

"lang" : "en-us",

"value" : "No matching records found (ODBC -2028)"

}

}

}

"

Part of my code is this.

Dim NewLine as New DocumentLine

newLine.BaseEntry= order1.DocEntry

newLine.BaseLine= lin.LineNum

newLine.BaseType= 15 ' Object delivery


The order1 is the Document to delivery.

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Apr 28, 2016 at 12:39 PM

    I guess you may miss the CardCode or something else.

    A complete payload to create an invoice based on a delivery should be like this:

    POST /b1s/v1/Invoices

    {

    "DocDate": "2016-02-23",

    "DocDueDate": "2016-02-23",

    "CardCode": "bp004",

    "DocumentLines": [

    {

    "BaseType": 15,

    "BaseEntry": 14,

    "BaseLine": 0,

    "TaxCode": "x1"

    },

    {

    "BaseType": 15,

    "BaseEntry": 14,

    "BaseLine": 1,

    "TaxCode": "x1"

    }

    ]

    }

    By the way, why use VB? Personally, C# with WCF is preferred. Sample code:

     public static void AddInvoice(ServiceLayer slContext)
            {
                try
                {
                    Document oInvoice = new Document();
                    oInvoice.DocDate = DateTime.Today;
                    oInvoice.DocDueDate = DateTime.Today;
                    oInvoice.CardCode = "bp004";
                    for (int i = 0; i < DOCUMENT_LINES_COUNT; ++i)
                    {
                        DocumentLine line = new DocumentLine();
                        line.BaseType = 15;
                        line.BaseEntry = 14;
                        line.BaseLine = i;
                        line.TaxCode = "X1";
                        oInvoice.DocumentLines.Add(line);
                    }
                    slContext.AddToInvoices(oInvoice);
                    slContext.SaveChanges();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            }
    
    Add a comment
    10|10000 characters needed characters exceeded

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.