Search code examples
quickbooksqbxml

QBXML - modifying Sales Order line item custom field


I have a custom field set up in my QB sales order line items called Ready QTY, and I want to use QBXML to update the value. Here is a test QBXML request:

<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="13.0"?>
<QBXML>
    <QBXMLMsgsRq onError="stopOnError">
        <DataExtModRq>
            <DataExtMod>
                <OwnerID>0</OwnerID>
                <DataExtName>Ready QTY</DataExtName>
                <TxnDataExtType>SalesOrder</TxnDataExtType>
                <TxnID>52FC6-1504808512</TxnID>
                <TxnLineID>52FC8-1504808512</TxnLineID>
                <DataExtValue>3</DataExtValue>
            </DataExtMod>
        </DataExtModRq>
    </QBXMLMsgsRq>
</QBXML>

My other QBXML requests to the Web Connector work fine (I'm using Keith Palmer's awesome SDK, thanks Keith!).

I think I have the request right, at least according to the reference (https://developer-static.intuit.com/qbSDK-current/Common/newOSR/index.html) under the DataExtMod method. However, QB Web Conenctor returns this error message:

0x80040400: QuickBooks found an error when parsing the provided XML text stream

The XML validates, and I can't seem to figure out what I'm doing wrong. Has anyone tried to update Sales Order line item custom fields before? Any help?

The issue above is solved, but I have a RELATED QUESTION that is still unsolved:

Do I need to put this DataExtModRq inside of a SalesOrderModRq? It doesn't seem that way as I look at the OSR. And it seems like data exts in QB work differently than other entities where I'd pass an EditSequence somehow in order for QB to actually update anything... I'm just passing the TxnID and TxnLineID of the Sales Order line item as well as the data field name I want updated. QBWC is running my requests without errors and I'm getting a good return XML back in my response handler, but QB itself is not showing the updated value in the field. Is there a setting in QB or something I don't know about?

The TxnID of the Sales Order I want to modify is 530C4-1504813938, and the TxnLineID is 530C6-1504813938. I've changed these individually to bogus values to test my request and QBWC does indeed return an error, as expected.

Here's what it looks like on a Sales Order itself:

IMAGE: Screenshot - Ready QTY field on a Sales Order

Here's some relevant PHP code to what I'm doing.

Map QuickBooks actions to handler functions:

$map = array(
QUICKBOOKS_IMPORT_SALESORDER => array('_quickbooks_salesorder_import_request', '_quickbooks_salesorder_import_response' ),
QUICKBOOKS_MOD_DATAEXT => array( '_quickbooks_salesorder_update_request', '_quickbooks_salesorder_update_response' ),
);

The request itself:

function _quickbooks_salesorder_update_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale)
{
$xml = '<?xml version="1.0" encoding="utf-8"?>
    <?qbxml version="13.0"?>
    <QBXML>
        <QBXMLMsgsRq onError="stopOnError">
              <DataExtModRq>
                  <DataExtMod>
                    <OwnerID>0</OwnerID>
                    <DataExtName>Ready QTY</DataExtName>
                    <TxnDataExtType>SalesOrder</TxnDataExtType>
                    <TxnID>530C4-1504813938</TxnID>
                    <TxnLineID>530C6-1504813938</TxnLineID>
                    <DataExtValue>6</DataExtValue>
                </DataExtMod>
            </DataExtModRq>
        </QBXMLMsgsRq>
    </QBXML>';

return $xml;
}

Then I enqueue the request:

$Queue = new QuickBooks_WebConnector_Queue($dsn);
$Queue->enqueue(QUICKBOOKS_MOD_DATAEXT);

I run QBWC and I get no errors. The response XML I receive and print out from my response handler is:

[12-Oct-2017 09:47:56 America/Chicago] <?xml version="1.0" ?>
<QBXML>
<QBXMLMsgsRs>
<DataExtModRs requestID="252" statusCode="0" statusSeverity="Info" statusMessage="Status OK">
<DataExtRet>
<OwnerID>0</OwnerID>
<DataExtName>Ready QTY</DataExtName>
<DataExtType>STR255TYPE</DataExtType>
<DataExtValue>6</DataExtValue>
</DataExtRet>
</DataExtModRs>
</QBXMLMsgsRs>
</QBXML>

This makes it look to me like the value was updated... However, I look at the particular sales order and line item in QB, and the value is still "4" and not "6".

Is there anything else I can do to see why it is not updating? Or is there a step that I'm missing in the process?


Solution

  • Well, I did some research and answered my own question. I ended up using the QBXML validator included in the SDK that Intuit provides as a free download. My problem was that I was specifying an old version of QBXML ("2.0") instead of something much more recent.

    So the solution was to add:

    <?qbxml version="13.0"?>
    

    to the top of the request. It was not validating correctly because I originally had

    <?qbxml version="2.0"?>
    

    I had cut and pasted it from somewhere else, and initially didn't realize that the version number mattered as much as it does.

    I edited the OP so that the QBXML is actually valid now.

    Hope this helps anyone else who runs into a similar issue!