Quickbooks create invoice get generated invoice ID

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Cloud Applications
Post Reply
Posts: 4
Joined: Sun 30 Sep 2018 20:47

Quickbooks create invoice get generated invoice ID

Post by tklawsuc » Mon 01 Oct 2018 18:25

I'm using QuickBooksCommand to create an invoice. How do I get the DocNumber and Id from the generated invoice? I tried using parameters with direction set to output but this fails with "Specified method not supported".

Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: Quickbooks create invoice get generated invoice ID

Post by Pinturiccio » Tue 02 Oct 2018 14:50

You need to add "RETURNING Id, DocNumber" at the end of insert query and read these values via QuickBooksDataReader. Here an example of simple Windows Forms application:

Code: Select all

public Form1()
    QuickBooksCommand comm = quickBooksConnection1.CreateCommand();
    comm.CommandText = @"INSERT INTO Invoice (DocNumber, Line, CustomerRefId) VALUES (NULL, '[
""Amount"": 0,
""Description"": ""Custom Devices"",
""DetailType"": ""SalesItemLineDetail"",
""SalesItemLineDetail_ItemRefId"": ""5"",
""SalesItemLineDetail_ItemRefName"": ""60"",
""SalesItemLineDetail_Qty"": 1.0
]', '9') RETURNING Id, DocNumber";
    QuickBooksDataReader reader = comm.ExecuteReader();
    MessageBox.Show("New invoice Id = " + reader.GetValue("Id").ToString());
    MessageBox.Show("New invoice DocNumber = " + reader.GetValue("DocNumber").ToString());

Post Reply