DavidRouyer / pipedrive-dotnet

Pipedrive.net is an async .NET Standard client for pipedrive.com
MIT License
38 stars 46 forks source link

Search Organization by custom fields #87

Open Maruga opened 3 years ago

Maruga commented 3 years ago

hi, I want to search for an organization through a custom field, but it finds me all the organizations that contain 70, I tried to enter ExactMatch both true and false but it doesn't work. Any suggestions? thank you very much

        Dim filtriRicerca As New OrganizationSearchFilters()
        filtriRicerca.Parameters.Add("custom_fields", "COD. CLIENTE")
        Dim Organizations = Await Pipedrive.Organization.Search("70", filtriRicerca)
DavidRouyer commented 3 years ago

Hi, you can't search by a specific custom field: https://developers.pipedrive.com/docs/api/v1/Deals#searchDeals. However, I'll add the news fields parameter which allows to specify the fields to perform the search from.

dombarnes commented 2 years ago

IIRC you can't add parameters in that way. They are generated when you set other fields. If you breakpoint your code before calling the search, you'll see that your parameters didn't add.

Try this. You may need to do your own filtering once you get search results, depending on what you're searching.

var searchQuery = new DealSearchFilters();
searchQuery.OrganizationId = crmOrg.Id;
searchQuery.Fields = DealSearchField.custom_fields;
var searchResults = await _pipedriveClient.Deal.Search("your custom field value", searchQuery);