Question regarding how to set ‘is a sub-customer’ and select its parent using the Quickbooks API

The below code shows how I am trying to create a sub customer. However this code fails.

Here is what I know:

  1. This code works if the ‘ParentRef’ section is excluded.
  2. $parentid does exist (94 in this case) and is the ID of an existing Customer.
  3. I have followed and referred to https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/customer to get here.
           $customer = $dataService->Add(Customer::create([
            "DisplayName" => $formvars["fullname"],
            "CompanyName" => $formvars["clientname"],
            "BillAddr" => [
                "Line1" => $formvars["addrh1"],
                "Line2" => $formvars["addrh2"],
                "City" => $formvars["addrc"],
                "CountrySubDivisionCode" => $formvars["addrs"],
                "PostalCode" => $formvars["addrz"],
            ],
            "ShipAddr" => [
                "Line1" => $formvars["addrh1"],
                "Line2" => $formvars["addrh2"],
                "City" => $formvars["addrc"],
                "CountrySubDivisionCode" => $formvars["addrs"],
                "PostalCode" => $formvars["addrz"],
            ],
            "PrimaryEmailAddr" => [
                "Address" => $formvars["email"]
            ],
            "PrimaryPhone" => [
                "FreeFormNumber" => $formvars["phext"],
            ],
            "ParentRef" => [
                "value" => $parentid,
            ]

        ]));
        if ($customer) {
            echo $customer->Id;
            exit;
        } else {
            echo "Error creating sub-customer: " . $customer->message;
            exit;
        }

Does anyone know what I am missing here?

I forgot to include

"Job" => true,

In the above lines to determine that this is actually a sub-customer to begin with.

I will leave this post up for anyone who has or will have the same issue that I have.

Leave a Comment