GET a deal by a custom field's value

I need to be able to access Pipedrive resources by fields that I have created.

Creating and getting deals by the Pipedrive Deal ID is easy, simply call a Get on the specific resource, I get that. But without a matching key between my application and Pipedrive, I don’t have a really good way to match or fetch the pipedrive deal resource that correlates with the object in my application.

I’d like to put a custom field on the deal, something like application_id and then be able to do something like
GET /deals/?application_id=<whatever>

The only similar thing I’ve found is “GET /deals/find” - but I don’t think this is the right way to do this. This fetches the deal by its Title-- What if someone in pipedrive changes the title of the deal, but the application is not updated? I won’t be able to find the deal. I need to basically store my application-level object ID on the Deal and with confidence know that I have fetched the right Pipedrive deal that relates to it.

Is there a way to do this type of thing currently? Otherwise, I would have to fetch all deals, store them in a container, loop through each entry, decode the weird hash I get for custom fields, and then find the matching entry for every single deal.

Hey Rob, not sure what the exact situation is, but is there a reason you don’t use the Deal ID as the matching key between your app and Pipedrive?
Not sure what your app setup is like so maybe it’s that there’s a default ID built into that already or something similar?

I’m probably not explaining this well…apologies.

Maybe this example might make it clearer.

Lets say I have a bunch of objects like this in my application

Class Account(object):
    id = 18792
    name = 'rob'
    email ='rob@isgreat.com'

Lets say I have 20,000 objects like this in my application. And lets say 15,000 of them have a corresponding Pipedrive deal.

A week goes by, and in my application, account 18792 updates their email address. I’d like to push this chunk of info into Pipedrive so the sales team isn’t in the dark. So, I need to fetch a specific Pipedrive Deal, but I don’t have the Pipedrive deal ID in my application.

I don’t want to store the Pipedrive deal ID inside my Application’s account class, it’s much easier for me to simply store the Application’s account ID in the Pipedrive Deal as a custom field, lets say application_id and then fetch the deal based on that field.

Does that make more sense?

1 Like

I guess you could setup something that would search a field matching certain content, get return results which would include connected fields (Deal ID and email address field, etc) and then make an update after that, but that could be a bit of a headache to accomplish.
The main issue I see is there’s no way to create a custom Field where that account number from your application would be set as we don’t offer static custom fields.

Let me know if that suggestion works at all (or makes sense for that matter)

I’m not sure…What exactly is the suggestion?

I need to be able to set a field on a deal and then fetch the resource based upon that fields value. What are my options to do this? Basically, what filter options are available when I call a GET to /deals/?

It would make sense to be able to target a resource, i.e. /deals/ and then give an target attribute and value, such as /deals/?billing_id=abc123 that would return a JSON list of deals with a billing_id that matches or contains abc123. I believe this is pretty fundamental to REST.

If this type of thing isn’t possible it’s understandable, I’ll just probably have to try searching elsewhere for solutions.

Hey @rob,

maybe there is another (not tested) way to accomplish what you are looking for:

  1. Use the GUI to define a filter which holds a placeholder as value. Lets call the placeholder value “%APP_ID%”
  2. Store the filter_id somewhere in your application
  3. Everytime you need to get a collection of deals with a particular value on your customfield, first update the filter and replace %APP_ID% with the value you are searching for using /filters endpoint.
  4. Call /deals endpoint with parameter filter_id:<stored_filter_id>
  5. Update your filter and reset the placeholder value for future uses.

Its not a really convenient way but maybe a workaround if you don’t want to iterate over the whole deals-collection.

I believe I understand this strategy, but I don’t know if this will accomplish what I require in a reasonable manner. Is there any documentation about storing a placeholder value inside a filter? Is this relatively future proof?

It seems pretty convoluted to do this. Also, this will effectively double the amount of API calls I have to do. One to update the filter, and then another to fetch the deals (and potentially another if the resource requires updates). This potentially will create a lot more issues in rate management on my side.

Calling a resource with query params to filter data on is kind of inherent to REST architecture so I sort of figured there would be an out-of-box way to do this.

Is it possible to feed any query parameters to the /deals/ endpoint? Or do I have to create a new filter in the UI every time I want to fetch collections of deals with similar data?

Hey @rob, maybe https://developers.pipedrive.com/docs/api/v1/#!/SearchResults/get_searchResults_field does the trick for you? Would allow you to get deals by any value in any field.

Hope it helps!

1 Like