Reputation: 4420
When sending a CustomerQueryRq
in qbxml, it returns:
500: The query request has not been fully completed.
There was a required element ("Client Name") that could not be found in QuickBooks.
So then I send a CustomerAddRq
that returns:
3100: The name "Client Name" of the list element is already in use.
And the InvoiceAddRq
fails saying:
3140: There is an invalid reference to QuickBooks Customer "Client Name"
in the Invoice. QuickBooks error message: The specified name is either
invalid or of the wrong type.
How could the Customer with FullName "Client Name" already be in use, but then it is not found when trying to add an Invoice for that Customer?
Am I misinterpreting these error messages?
Upvotes: 1
Views: 547
Reputation: 9363
Note: Always escape and trim your data and check the length before it is passed to QB. Always refer to OSR.
First of all try to find a customer by name using CustomerQueryRq
xml:
// CustomerQuery Request
$name = 'John Doe';
$xml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="13.0"?>
<QBXML>
<QBXMLMsgsRq onError="continueOnError">
<CustomerQueryRq>
<NameFilter>
<MatchCriterion>StartsWith</MatchCriterion>
<Name>' . $name . '</Name>
</NameFilter>
</CustomerQueryRq>
</QBXMLMsgsRq>
</QBXML>';
Parse your response.
If something is found (there could be John Doe
and John Doe 1
, etc), check their email addresses. If match is found, bind its QuickBooks ID to the customer in your e-commerce DB. You will refer to this ID in further requests. Skip step #3.
If nothing is found, add a new customer (step 3).
Adding a customer. Use CustomerAdd XML now:
$name = 'John Doe';
$firstname = 'John';
$lastname = 'Doe';
$address_xml = ''; // Put address XML block here
$xml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="2.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<CustomerAddRq>
<CustomerAdd>
<Name>' . $name . '</Name>
<CompanyName></CompanyName>
<FirstName>' . $firstname . '</FirstName>
<LastName>' . $lastname . '</LastName>
' . $address_xml . '
<Phone>555-555-55</Phone>
<AltPhone></AltPhone>
<Fax>555-555-55</Fax>
<Email>[email protected]</Email>
<Contact>' . $name . '</Contact>
</CustomerAdd>
</CustomerAddRq>
</QBXMLMsgsRq>
</QBXML>';
Parse your request and store QuickBooks ID in your database to refer to it in future.
Build your InvoiceAdd XML and specify a customer ID (not Name):
$xml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="13.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<InvoiceAddRq>
<InvoiceAdd>
<CustomerRef>
<ListID>' . $id . '</ListID>
</CustomerRef>
<!-- rest of XML -->
';
Don't forget to save QuickBooks ID of just created invoice in your database.
Upvotes: 2
Reputation: 27952
This is your answer right here:
This tells me that there is NOT a customer with that exact name, but that there's a VENDOR or an EMPLOYEE or a OTHER NAME entry with the same name.
The Name
field in QuickBooks is a UNIQUE
key across Vendors, Employees, Other Name entries, and Customers.
Upvotes: 2