Search code examples
c#wcfquickbooksinvoiceqbxml

QBXML - How do I go about adding brand new items on the fly when i modify an Invoice using InvoiceModRq?


<?xml version="1.0" encoding="utf-16"?><?qbxml version="13.0"?><QBXML>
    <QBXMLMsgsRq onError="stopOnError">
        <InvoiceModRq>
            <InvoiceMod>
                <TxnID>983C-1639586336</TxnID>     
                <EditSequence>1639586895</EditSequence>    
                <RefNumber>308_17</RefNumber>        
                <Other>INVU</Other>    
                <InvoiceLineMod>
                     <TxnLineID>-1</TxnLineID>          
                        <ItemRef>
                           <FullName>MP3-C </FullName>
                      </ItemRef>          
                        <Desc>Harley Davidson 1950 80hp bike </Desc>         
                         <Quantity>1.00</Quantity>         
                         <Amount>5.00</Amount>     
                         <Other1>308_17</Other1>          
                          <Other2>13041</Other2>
                            </InvoiceLineMod>
                          </InvoiceMod>
                        </InvoiceModRq>
                      </QBXMLMsgsRq>
                    </QBXML>

At the company where I work, we have the following technologies in Dev environment - company's own C# web application called companyABCDevapplication - installation of Quick Books Web Connector - installation of Quick books Quickbooks Desktop 2017 Premier Trial Version

I've been tasked with creating an interfacing Web service that will be invoked by a Quick Books Web Connector Installation to communicate with our companyABCDevapplication

Here are the technologies being used for local development:

  • Intuit Quickbooks Desktop 2017 Premier Trial Version

  • Intuit QuickBooks Web Connector Version 2.2.0.71

  • Microsoft Visual Studio Enterprise 2015

  • Version 14.0.25431.01 Update 3

  • Microsoft .NET FrameworkVersion 4.6.01055

Unfortunately, when I send the XML shown at the top of this post to Quickbooks Web connector, I get the following error:

<?xml version=\"1.0\" ?><QBXML>
  <QBXMLMsgsRs>
    <InvoiceModRs statusCode=\"3140\" statusSeverity=\"Error\" statusMessage=\"There is an invalid reference to QuickBooks Item &quot;MP3-C&quot; in the Invoice. \" />
  </QBXMLMsgsRs>
</QBXML>

I wanted to modify an Invoice withOut worrying about whether the ItemRef in questionis already known by Quickbooks. I basically want to new Item that have Not been entered into Quickbooks by using ItemInventoryAdd tags or ItemNonInventoryAdd tags. How do I go about adding brand new items on the fly when i modify an Invoice using InvoiceModRq?


Solution

  • How do I go about adding brand new items on the fly when i modify an Invoice using InvoiceModRq?

    You can't.

    QuickBooks does not allow you to do what you're trying to do.

    What you can do, is sort of fudge it by ALWAYS sending a ItemInventoryAddRq immediately preceding your InvoiceAddRq or InvoiceModRq node, to essentially always try to re-create the item prior to doing your invoice.

    If the item already exists, the add will fail with an error, but the next request will still be processed.

    If you do this bundled in a single QBXMLMsgsRq then you'll want to make sure you use:

    onError="continueOnError"

    Instead of:

    onError="stopOnError"

    So that QuickBooks continues processing the rest of the requests even if the item add requests fail.