pipedrive / client-php

Pipedrive API client for PHP
MIT License
49 stars 57 forks source link

Cannot update person custom fields #15

Closed mschop closed 3 years ago

mschop commented 4 years ago

Hi,

I am just trying to update a person. It is working, except the custom fields of a person. Those are not handled by the PersonController. This seem to be a great bug in the code. When I add the following lines in the method PersonController::updateAPerson in line 455 it seems to work:

foreach ($options as $key => $value) {
    if (!in_array($key, ['id', 'name', 'owner_id', 'org_id', 'email', 'phone', 'visible_to'])) {
        $_parameters[$key] = $value;
    }
}

This is clearly a bug in this lib for me and makes the whole lib pointless/useless.

DenisButCheR commented 4 years ago

Hello @mschop . Currently, there is no support for Custom Fields in Persons or Deals. We are working on this and will provide this support in future versions of the library.

Thanks for your report.

ikleiman commented 4 years ago

Just ran into this same issue trying to update an organization. Making a direct API call works without any problem, but could you please state this in the SDK docs? Had to spend several hours doing tests and talking with Pipedrive support, before using the direct call as a last resource. The whole idea of using a SDK is to not have to develop your own connector.

zeman commented 3 years ago

This library is basically pointless without support for custom fields. @DenisButCheR can we get an up date please. It's starting to feel like this library has been abandoned by Pipedrive.

Koberum commented 3 years ago

Okay got it. You can't update custom fields with this SDK. Can you please note it under your documentation? I wasted my time searching around for nothing

alex-bukach commented 3 years ago

@zeman @ikleiman @Koberum did you try the fix I provided in https://github.com/pipedrive/client-php/pull/16?

dynamodan commented 3 years ago

This also leaves out some fields that appear to be newer, such as the deal field expected_close_date. I saw the nifty callOnBeforeRequest callback provided, and it would allow you to add more stuff to the parameters:

         //call on-before Http callback
        $_httpRequest = new HttpRequest(HttpMethod::PUT, $_headers, $_queryUrl, $_parameters);
        if ($this->getHttpCallBack() != null) {
            $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest);
        }

But instead of fetching the parameters from the $_httpRequest using $_httpRequest->getParameters(), when the api call is sent, it just does this:

$response = Request::put($_queryUrl, $_headers, Request\Body::Form($_parameters));

Note $_parameters. I fiddled around with trying to set the $_parameters array as a reference using &, but no luck there either.

ziimk commented 3 years ago

Thank you for the patience and suggestions. The changes implemented in https://github.com/pipedrive/client-php/pull/48 should fix the issues with updating custom fields in deals, persons and organizations endpoints. Feel free to test it out