Topic: API modifyCustomer

In my attempt to update customers with the API, I may have discovered a bug. OR im just doing something wrong.

$API->modifyCustomer

The QBXML that gets caught as an error in my queue is missing a required "EditSequence" immediately after "ListID" according to the validation tool. I have tried manually pulling it down and setting with the setEditSequence in an effort to force the output,  but no go.

This is my logic:

// Create new customer object from existing customer
$Customer = new QuickBooks_Object_Customer($CustomerID);

// change some properties
$Customer->setCompanyName($cpname);
$Customer->setContact($ctname);
$Customer->setPhone($phone);
$Customer->setEmail($email);
$Customer->setFax($fax);
$Customer->setBillAddress($addr1, $addr2, $addr3, $addr4, $addr5, $city, $state, $province, $postalcode, $country);

// commit changes back to QuickBooks
$API->modifyCustomer($Customer);

is this wrong? im using a nightly build from 6/25/2010 and im gonna pull the new one down and see if that helps. Thanks in advance for the direction.

Re: API modifyCustomer

What  you're describing *should* work. Can you post the actual error message you get, the code you're using where you're setting the ListID/EditSequence, and the actual outgoing qbXML request?

Also, are you using this with QuickBooks Online, or some QuickBooks desktop edition?

Re: API modifyCustomer

Here is the xml that tosses the validation error:

<?xml version="1.0" encoding="utf-8"?>
            <?qbxml version="8.0"?>
            <QBXML>
                <QBXMLMsgsRq onError="stopOnError"><CustomerModRq>
    <CustomerMod>
        <ListID>80000006-1279255207</ListID>
        <Name>Ronald McDonald</Name>
        <CompanyName>McDonald's</CompanyName>
        <BillAddress>
            <Addr1>McDonald's</Addr1>
            <Addr2>1234 5th St</Addr2>
            <City>Hollywood</City>
            <State>CA</State>
            <Country>USA</Country>
        </BillAddress>
        <Phone>800-123-4567</Phone>
        <Email>ronald@mickeyds.com</Email>
        <Contact>Ronald McDonald</Contact>
    </CustomerMod>
</CustomerModRq>
</QBXMLMsgsRq>
            </QBXML>

The code above is what produced this. The variable '$CustomerID' above is the ListID passed into the new customer object. The variables are pulled from post data and even when i add the line:

$Customer->setEditSequence($edSeq); 

The QBXML still comes out the same... expected: EditSequence provided in the QBXML validation error. How well have your _doMod and modifyCustomer methods been tested in the API? Is it possible there is something missing or a little off? I'll poke around a little and test my code more.

Re: API modifyCustomer

Strange. It's certainly possible there are bugs in the code.

What do you get if you dump your object to qbXML?

print($Customer->asQBXML(QUICKBOOKS_MOD_CUSTOMER));

Re: API modifyCustomer

consolibyte wrote:

Strange. It's certainly possible there are bugs in the code.

What do you get if you dump your object to qbXML?

print($Customer->asQBXML(QUICKBOOKS_MOD_CUSTOMER));

That constant returned an error but i got the point so, I just used this:

print($_POST('EditSequence'));
print('<br/>');
print($Customer->getEditSequence($CustomerID));
print('<br/>');
print($Customer->asQBXML('CustomerModRq'));

With this method I did find my edit sequence was getting lost between posts (typo in input tag name). Thanks for your help on this!

Re: API modifyCustomer

jeremy.bradbury wrote:
consolibyte wrote:

Strange. It's certainly possible there are bugs in the code.

What do you get if you dump your object to qbXML?

print($Customer->asQBXML(QUICKBOOKS_MOD_CUSTOMER));

That constant returned an error but i got the point so, I just used this:

print($_POST('EditSequence'));
print('<br/>');
print($Customer->getEditSequence($CustomerID));
print('<br/>');
print($Customer->asQBXML('CustomerModRq'));

With this method I did find my edit sequence was getting lost between posts (typo in input tag name). Thanks for your help on this!


OK, a few things:

1. You're calling ->getEditSequence(). You should be calling ->setEditSequence(). And I don't know why you're passing in $CustomerID to it. You should be passing in an EditSequence value.

2. ->asQBXML('CustomerModRq'); is not correct. You should be using ->asQBXML(QUICKBOOKS_MOD_CUSTOMER). If that's throwing an error or a warning, then I need to know what the warning is so I can determine why that's happening. It should not be throwing an error or warning or anything at all.

3. Can you post a *full code example* that illustrates the behavior you're talking about? Something that doesn't depend on $_POST content and that I can actually just throw in a .php file and run so I can see what you're seeing?