Question

I am developing a program which will query Quickbooks with a set of invoice numbers, and then against each invoice no. will get invoice, the invoice numbers will come primarily from a file. and the numbers which have problems that is they don't have a matching record in quick book will be saved in another file.

Now that I add all the invoice numbers in the RefNumberList as I have hard coded two numbers in the following example

IInvoiceQuery Invoices = msgset.AppendInvoiceQueryRq();
Invoices.ORInvoiceQuery.RefNumberList.Add("144");
Invoices.ORInvoiceQuery.RefNumberList.Add("9999");

msgset.Attributes.OnError = ENRqOnError.roeContinue;

if (sessionMgr.doRequests(ref msgset))
{
     MessageBox.Show("An error was detected while processing the request. Please check the log files");
     return;
}

The main problem is that if even any one of the invoice number fails to have a record in the quick books, entire query fails.

Was it helpful?

Solution

I would suggest that you make each invoice a separate request. That way you will still get the other queries returning a value.

msgset.Attributes.OnError = ENRqOnError.roeContinue;
string[] InvoiceList = { "144", "9999" };
foreach (string invNum in InvoiceList)
{
    IInvoiceQuery invQuery = msgset.AppendInvoiceQueryRq();
    invQuery.ORInvoiceQuery.RefNumberList.Add(invNum);
}

// Process the requests and get the response IMsgSetResponse MsgResponse = SessionManager.DoRequests(msgset);

// Check each response for (int index = 0; index < MsgResponse.ResponseList.Count; index++) { IResponse response = MsgResponse.ResponseList.GetAt(index); if (response.StatusCode != 0) { // Save the invoice number in the "not found" file // and display the error MessageBox.Show("Error finding invoice " + InvoiceList[index] + ". Error: " + response.StatusMessage); } }

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top