1
votes

I'm working on code to import invoices created in a custom application into QuickBooks using the QODBC driver. I have things nearly working, but I'm running into a problem with the INSERT that adds the actual invoice record. My overall code is based on the model laid out at http://support.flexquarters.com/esupport/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=10726&nav=0,58,64.

In this particular case, the INSERTs into the InvoiceLine table are working, but the INSERT into Invoice fails with this error:

[QODBC] Error: 3140 - There is an invalid reference to QuickBooks Item "" in the Invoice line.

Here's the INSERT command that I'm sending in this case:

INSERT INTO Invoice (CustomerRefListID, ARAccountRefFullName, TxnDate, RefNumber, TermsRefFullName, TemplateRefFullName, SalesRepRefListID, ClassRefListID)
  VALUES ('80000855-1326914216', 'Receivables', {d '2012-01-17'}, '12-1005', '30 days', 'Customized Invoice', '30000-1034349330', '8F70000-912629594')

The values for CustomerRefListID, SalesRepListID, and ClassRefListID are all determined by doing look-ups into the respective tables. I've also confirmed that '30 days' occurs in the Terms table.

An earlier version of the code that generates this command was working a few days ago with different data. It used SalesRepRefFullName and ClassRefFullName. I modified it because of the failure of this case, thinking that perhaps the strings I had available didn't always exactly match the fullnames.

Any suggestions welcomed.

Tamar

2
This has gotten more interesting. I isolated the INSERT commands (for InvoiceLine and Invoice) and sent them one at a time; when I do it that way, the exact same sequence of Inserts runs without issue. But when I step through my code that builds the commands and sends them, the final insert fails as described above. I'm sure the INSERT commands are the same because I wrote them to a log from the program and cut and pasted from there to do the manual test. Could some other SQL command in between the INSERTs be causing the problem? The only commands I'm sending are SELECTs to get ListIDs.Tamar E. Granor

2 Answers

1
votes

Solved it. It turned out that the Item referenced was in one of the line items, not the invoice itself. I'd missed noticing that a RefID in one of the line items was empty.

Definitely not a useful error message.

0
votes

Item does not exist in Quickbooks . first create it in Quickbooks and only then you can reference it in invoice .