Open BarnumD opened 1 year ago
Same problem here. I also see that running a query in the API Explorer doesn't return custom fields either.
Here's how I was able to achieve this (took me a very long time to figure it out :-( ):
<?php
/** @var \QuickBooksOnline\API\DataService\DataService $dataService */
$preferences = $dataService->getCompanyPreferences();
/** @var \QuickBooksOnline\API\Data\IPPSalesFormsPrefs $salesFormPreferences */
$salesFormPreferences = $preferences->SalesFormsPrefs;
/** @var list<\QuickBooksOnline\API\Data\IPPCustomFieldDefinition> $defs */
$defs = $salesFormPreferences->CustomField;
// custom field names indexed by ID
$customFieldsParsed = [];
if (count($defs) > 1) {
/** @var list<\QuickBooksOnline\API\Data\IPPCustomField> $customFields */
$customFields = $defs[1]->CustomField;
foreach ($customFields as $customField) {
$customFieldId = \substr($customField->Name, -1);
$customFieldsParsed[$customFieldId] = $customField->StringValue;
}
}
\var_dump($customFieldsParsed);
?>
cliffordvickrey said: Here's how I was able to achieve this...
Thanks very much for looking into this!
However, this isn't really what I'm looking for (or what the OP is looking for either, I think). When I run your code, I get a list of three custom field names:
customFieldsParsed:
array(3) {
[3]=> string(18) "Collection Ranking"
[2]=> string(9) "Sales Rep"
[1]=> string(11) "P.O. Number"
}
But I'm looking for the actual values for these custom fields when querying customers, not just the custom field names. So for example, I want to know what the "Collection Ranking" is for each customer.
And curiously, I actually have several more custom fields that aren't included in the array above. When I edit a customer and scroll down to the "Custom fields" section, I see only one of the three fields listed above ("Collection Ranking"), plus five more that aren't listed.
I think that's because when I go to the gear icon, then "Custom fields", I see that "Collection Ranking" has a category of "Customer", while "Sales Rep" and "P.O. Number" have a category of "Transaction". But I don't understand why the other five "Customer" category fields aren't in the array above with "Collection Ranking", even though they have the exact same permissions as "Collection Ranking".
I've gone into the QBO GUI to a customer, created a custom field, populated the field, then tried to call the customer via the API
The resulting customer object has a blank customfields section:
[CustomField] =>